Log in

View Full Version : ICD and USB UART device



Demon
- 11th April 2023, 03:51
Just received this device (FTDI USB UART IC FT232RL):
https://www.amazon.ca/Adapter-Serial-Converter-Development-Projects/dp/B075N82CDL

Has anyone been able to use a USB UART device to use ICD in Microcode Studio? Or any RS232 device for that matter?

I'm using PBP v3.0.8.4, MCS+ v5.0.0.5 and a Blinky program on 16F877:


#CONFIG
__config _HS_OSC & _WDT_OFF & _WRT_OFF & _BODEN_ON & _LVP_OFF & _CPD_OFF & _PWRTE_OFF & _DEBUG_OFF
#ENDCONFIG

DEFINE OSC 20

ADCON1 = 7 ' A/D off, all digital

TRISD = %00000000
PORTD = %00000000

START: PORTD = %00100000
PAUSE 500
PORTD = %00000000
PAUSE 500
GOTO START

Finish: end

I have GND connected, TX on device to RX on PIC, RX on device to TX on PIC.

It compiles normally using ICD Compile/Program, I add a Break at PAUSE 500 to stop it, I select COM4 (confirmed in Device Manager, FTDI is there) and click RUN.

It just sits there, until a window shows up with MCS offering me ideas on things to check.

richard
- 11th April 2023, 06:55
Has anyone been able to use a USB UART device to use ICD in Microcode Studio? Or any RS232 device for that matter?

never in a reliable way , ever

apita making a separate model to suit every different osc and config variation for every chip i use .
and after all that effort to be met errors or a stubborn refusal to connect or it only works for a few minutes , then you need to recompile to continue, just junk imo a total waste of time.
xc8 mplabx , wonderful, better than arduino ide for debugging too

Ioannis
- 13th April 2023, 16:20
Did you check the USB-UART if it works with a serial output from PIC to PC?

Ioannis

Demon
- 15th April 2023, 02:18
Did you check the USB-UART if it works with a serial output from PIC to PC?

Ioannis

I haven't done any serious test except plugging it on day 1 and trying it using ICD and MCS+5, like a kid on Christmas morning.

The circuit has CTS, RTS, RXD, TXD, GND and VCC; that leads me to believe it's capable of the same communication as our old MAX232 ICs. It might even be faster for all I know; I have no docs on this device.

It seems to be the new thing for UART communication over USB, but these boards all seem to love the FT232RL IC. Even Sparkfun likes it:
https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/meet-the-ft232rl

But you're right; I have no clue how this affects the serial component of USART comms. At this point, I mistrust myself as much as this new components (I've been out of the loop for so long).

I was hoping one of us had used these with success. If all else fails, I'll do like before and resort to LEDs and LCDs to debug my project. :) I do remember something about USB and interrupts in general not liking ICD - or something of the sort, which sucks cause my project is mainly USB.

My old 16F877 support both USART and UART comm, so does the SAM E70 in a PICKIT4. I don't see why this would be a problem, unless Microcode Studio absolutely needs serial, but again, I don't see why, since it's seeing the new COM4 from the PICKIT4.

I'll try some basic serial exchanges with MCS once I get my LCD wired up. Right now I'm up to my eyeballs learning C++ and VB.NET using Visual Studio 2022.

Demon
- 15th April 2023, 06:14
Did you check the USB-UART if it works with a serial output from PIC to PC?

Ioannis

I might be doing a lot more testing on that UART device real soon. I was researching C++ code for Microsoft Flight Simulator 2020 and found this little gem.

https://forums.flightsimulator.com/t/tool-to-connect-serial-usb-devices-to-msfs2020-via-simconnect-wasm-using-vs2022/514651/2

I can't believe I had never thought of using the UART device as my main commmunication device for my project, I was only planning on using it for ICD.

Turns out I may not even have to bother with the whole generate-USB-code problem (MCS generates VB5, I'm using VB.NET - I don't even know yet how much code modifications that would require).

I remember testing USART at relatively high speeds with decent success.

Ioannis
- 17th April 2023, 09:19
I have not done anything yet with simulators but I think the data required is not that much. So Serial communication is enough for your needs.

I do use regularly a small FTDI232 board that has Tx, Rx, GND and +5V as outputs with great success on Laptops that lack real serial ports. These little boards do not support other serial control lines though (CTS, RTS etc) and are made by a friend of mine here in Greece.

In general I remember only one USB-2-Serial device that had problems. Can't remember what brand it was, but for sure it was a driver issue.

I do not see why the MCS will not work. Just be sure that your adapter works with a simple test.

I am glad you are delving into C++ and Visual Studio, something I always wanted to do but never had the nerve to.

Ioannis

mpgmike
- 21st April 2023, 00:40
You mention learning C++ then reference VB v5 and VB.net. Are you learning a couple? I started with the PC programming using Visual Basic v2015. I don't use it that often, and must consult the 5 books I bought when I dove in trying to learn.

Demon
- 23rd April 2023, 01:28
I'm forced to use whatever example code I can find for my purpose.

So far C++ seems the top candidate.

Demon
- 25th April 2023, 23:17
I've put aside my UART device, and finished my programming cable for my Lab X1 board (parts finally came in). It was getting annoying switching the PIC from ZIF to Lab X1 all the time.

9363

The cable connections for the MeLabs 40-pin ZIF board are different than their Lab X1. At least I incorporated the pull-up resistor in the connector so my circuits can be programmed by another device if the need ever arrizes.

tumbleweed
- 26th April 2023, 11:52
At least I incorporated the pull-up resistor
What "pull-up resistor" is that? Is there something missing from the X1 board?

Demon
- 27th April 2023, 05:20
The instructions seem a little vague, saying it can be configured for both ICSP and ICD. But it only mentions the pull-up in the ICD section.

"The debugger system can be configured to use standard ICSP communication for both
programming and debugging functions."

So I hid one in the hotglue and the ICSP seems to run fine. The hotglue is not elegant, but it keeps all the fine wires separated and adds A LOT of strength to the connector.

9373

Demon
- 27th April 2023, 05:34
What "pull-up resistor" is that? Is there something missing from the X1 board?

The pull-up on the Lab X1 is only 1K, the PK4 wants 10-50K. So I slapped in something in the 20K range; whichever one I had the most.

The 1K probably might have been enough, but I'm getting enough pesky problems without creating more of my own. :)

9374


Example of pesky problem: trying to get example code taken from the MSFS SDK docs to work. Except, the example code is missing a parameter.
Took me a while to track down the problem. The DEVs were really helpful though. Had a few of these pesky problems since I started this project.

9375

tumbleweed
- 27th April 2023, 11:27
The instructions seem a little vague, saying it can be configured for both ICSP and ICD. But it only mentions the pull-up in the ICD section.
The PIC ICSP and debug connections are the same. In Table B-5, ignore the "debug" column (that's not for a PIC device) and just use the ICSP column connections.

Whatever you add externally to the VPP/MCLR is just going to go in parallel with the 1K on the X1 board (lowering the R), so I'd remove it.

Do you have the JP1 jumper installed? If you tell the PK to use target power then it must be connected as it uses the target VDD connection to power the output drivers of the ICSP lines.

Demon
- 27th April 2023, 20:41
The PIC ICSP and debug connections are the same. In Table B-5, ignore the "debug" column (that's not for a PIC device) and just use the ICSP column connections.

Yeah, I realized that after I posted that pic and started googling those acronyms. :)



Whatever you add externally to the VPP/MCLR is just going to go in parallel with the 1K on the X1 board (lowering the R), so I'd remove it.

Having 1K in parallel with 20K shouldn<t have an impact when the allowable range is 10-50K, I would think.



Do you have the JP1 jumper installed? If you tell the PK to use target power then it must be connected as it uses the target VDD connection to power the output drivers of the ICSP lines.

Yup, JP1 is ON, I use an external power supply for the Lab X1. I have a fear of overloading USB ports on my PCs, practically a phobia. :)



I'm taking a mental break from trying to get ICD working on my PK4. I still haven't investigated that other "ICD" command line that I found (although part of me is afraid that only works from MPLABX).



I'm in the process of finishing up a tutorial on adding a COM port in Visual Studio to a basic GUI using C++. I have some MCP2221A-I/P coming in from Newark, so I'm going to investigate using UART. These USB ICs gets recognized as an ordinary serial port in Windows.

I got frustrated with the pains of MCS+5 generating obsolete USB code in C++ version6 (that's like 25 years old). Despite DT's efforts to simplify matters in PBP, I just find the whole USB connectivity thing cumbersome.

tumbleweed
- 27th April 2023, 23:14
Having 1K in parallel with 20K shouldn<t have an impact when the allowable range is 10-50K, I would think.
You might want to rethink that. What's 1K in parallel with 20K?

Although to be honest, I've used 1K before without too many issues.

Ioannis
- 29th April 2023, 20:54
Get rid off the 1K resistor. LABX1 was on a very safe side with this value and with 20K in parallel you are now less than 1K.

Are you trying to have ICD with Basic?

Ioannis

tumbleweed
- 30th April 2023, 11:22
Wouldn't it be better to just change the 1K to a 10K on the X1 and get rid of the extra resistor in the cable?
That way you still have the MCLR pullup on the board.

Ioannis
- 30th April 2023, 19:22
Robert said he had 20k in parallel with 1K. So a 20K I think is just fine.

Ioannis

Demon
- 1st May 2023, 21:55
Thanks for the ideas:

I've made a new cable without any built-in resistors.

I've also put aside my X1 for now, I'll change that 1K pull-up "soonday". :D

For now, I'm sticking with breadboards for USART testing.

Robert

Demon
- 3rd May 2023, 03:35
I've put aside my UART device, and finished my programming cable for my Lab X1 board (parts finally came in). It was getting annoying switching the PIC from ZIF to Lab X1 all the time.

9363
...


Guess what happens when you scroll to the very next page of the PK4 documentation? :D

9380

Ioannis
- 5th May 2023, 06:46
Well, seems you are hit by the RTFM thing! :smile:

Ioannis