UART Troubleshooting / Help - PIC16F689 + CP2102

Thread Starter

matrix7181

Joined Nov 8, 2012
9
The microchip lib does work for most pics but I am guessing the complier could be an issue. Are you certain they don't have their own lib?


You should try to at least afford a logic analyzer. I have a Zeroplus Logic Cube. While not the most serious LA on the market, it suits my needs and it is very affordable. It was worth it's weight in gold when I had similar serial port issues.
I did a quick look up for that one, on ebay listings are about $200.
Would you recommend a LA or for bit more saving up for a scope ?

Latest update :

I just installed the hi-tech-picc compiler, read somewhere they have samples, and indeed they do. In the samples folder used the code and programmed the pic. And well, guess what .. It doesn't work.

Also I have 4 USB2UART bridges, tried them all, and also plugged them in 2 at a time and interconnected the TX/RX RX/TX and they all work. So eliminated possible malfunction there.

Now I am wondering. What are the odds that that pin on the mcu is somehow malfunctioning ? Is there a way to test that ?

Tomorrow I'm gonna buy a new pic and try it. I've run out of things to try, going desperate. Don't understand how I managed to overcomplicate a simple thing. :(
 

spinnaker

Joined Oct 29, 2009
7,830
I did a quick look up for that one, on ebay listings are about $200.
Would you recommend a LA or for bit more saving up for a scope ?

Latest update :

I just installed the hi-tech-picc compiler, read somewhere they have samples, and indeed they do. In the samples folder used the code and programmed the pic. And well, guess what .. It doesn't work.

Also I have 4 USB2UART bridges, tried them all, and also plugged them in 2 at a time and interconnected the TX/RX RX/TX and they all work. So eliminated possible malfunction there.

Now I am wondering. What are the odds that that pin on the mcu is somehow malfunctioning ? Is there a way to test that ?

Tomorrow I'm gonna buy a new pic and try it. I've run out of things to try, going desperate. Don't understand how I managed to overcomplicate a simple thing. :(

Both are good tools but for mcus, if I had to choose I would go with a LA.

Where can you just go out and buy a pic? And on a Saturday??
 

Thread Starter

matrix7181

Joined Nov 8, 2012
9
Both are good tools but for mcus, if I had to choose I would go with a LA.

Where can you just go out and buy a pic? And on a Saturday??
You rustled my jimmies for a second. I misread Saturday as Sunday .. I'm "lucky" to live 5 minutes from an electronics shop. They sell active/passive components and all sort of stuff.

Funny enough they are the only place in the town where you can buy components for electronics here. Also, they are a bit expensive. But I'm just happy I don't have to order everything from ebay and wait for 4-5 weeks for a delivery.
 

spinnaker

Joined Oct 29, 2009
7,830
YI'm "lucky" to live 5 minutes from an electronics shop. They sell active/passive components and all sort of stuff.
I hate you. :)

Where do you live?


Nearest one to me is in Steubenville,OH about 30 mile from here but they have next to nothing and are open at odd hours. I am not even sure if they are open anymore.
 

Thread Starter

matrix7181

Joined Nov 8, 2012
9
I hate you. :)

Where do you live?


Nearest one to me is in Steubenville,OH about 30 mile from here but they have next to nothing and are open at odd hours. I am not even sure if they are open anymore.
Bosnia, Banja Luka :D

I bought PIC 16F628, and UART WORKS !!!!!!!!!!!!!!!

As for the PIC 16F628 .. It's slow, and has a bad feel .. I'm gonna try with a newer 16F689. The code is basically the same, except I specified RX on TRISB as input. And I thought that will solve the problem on 689 but it didn't.

I will investigate later why, but I'm just glad I made it to work :D

--Edit--

Hmm, I wanted to edit my first post but I can't.

So here is what I did to make it work for the future reference if someone finds it useful.

PIC16F628 - UART Setting Up
---

Without the external oscillator use the internal 4MHz one by :

Rich (BB code):
#pragma config FOSC = INTRCIO
Set the RB5 the RX pin as Input.
(I thought this is set automatically but it seems it didn't)

Rich (BB code):
//PORTB RX - Input RB5
TRISB = 0x02;
In the datasheet are the instructions on which bits to set for UART, but for reference here is what I used :

Rich (BB code):
    SPBRG = 0x19;//Page 165 / BaudRate 9600 @ 4MHz
BRGH = 1;

SYNC = 0;   //Asynchronous
SPEN = 1;   //enable serial port pins
CREN=1;     //enable reception
SREN = 0;   //No effect
TXIE=0;	//disable tx interrupts
RCIE=0;	//disable rx interrupts
TX9 = 0;    //8-bit transmission
RX9 = 0;    //8-bit reception
TXEN=0;     //reset transmitter
TXEN=1;     //enable the transmitter
All other code for transmission (simplified and without error detection / correction) is the same from the code I posted previously.
But for reference again here it is :

Rich (BB code):
...

//Receive
while(!RCIF);
        tmp_rcreg = RCREG;

...

//Transmit
while(!TXIF);
        TXREG = tmp_rcreg;
Also for the physical world, the circuit. Set you programator to 5V.
PIC 16F628 Has operating voltage 3V to 5.5V, but it took me unnecessary 5 minutes to read that the internal oscillator works only @ 5V ...

14.2.6 INTERNAL 4 MHZ OSCILLATOR
The internal RC oscillator provides a fixed 4 MHz
(nominal) system clock at VDD = 5V and 25°C, see
“Electrical Specifications” section for information
Also on the RX / TX Pin I had to strap on some 10k / and .3 M ohm resistors.
The values are accidental since those are the only I had currently. Without them it didn't work.


If someone could explain why, and how to calculate the proper values I would be thankful.
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Just wondering if this was a typo', John? I'm not aware of any way to clear the RCIF flag manually. I thought it could only be cleared by reading RCREG...
If only it were a typo. More like a senior moment. Of course you are correct, reading RCREG clears RCIF.. Apologies to the OP for any confusion and thanks for the correction.
 

spinnaker

Joined Oct 29, 2009
7,830
Bosnia, Banja Luka :D

I bought PIC 16F628, and UART WORKS !!!!!!!!!!!!!!!

Bosnia, Banja Luka
Congratulations!


Bosnia? Why is it that all of these little countries have electronics stores on every block and here in the high tech US, where we are always have the latest and the greatest gadgets, you can't find them anywhere?
 

Thread Starter

matrix7181

Joined Nov 8, 2012
9
Bosnia? Why is it that all of these little countries have electronics stores on every block and here in the high tech US, where we are always have the latest and the greatest gadgets, you can't find them anywhere?
Pfft man, don't complain. You can order anything and I mean anything and it will arrive like in 2 days to max 1 week.
I had to wait usb2uart and other stuff for a month :(
 

spinnaker

Joined Oct 29, 2009
7,830
Pfft man, don't complain. You can order anything and I mean anything and it will arrive like in 2 days to max 1 week.
I had to wait usb2uart and other stuff for a month :(

But I have to wait 2 days! :) And I have to pay for shipping. . :( Seriously that is what I hate. Not that I am cheap. Well I am but that is not it. :)

Just that I hate having to spend $6 for shipping when all I need to order is a 30 cent resistor. When I do order, I get real paranoid that I have not ordered everything I need for a project.
 

cmyers

Joined Apr 11, 2011
1
At the risk of necro-posting, I'd just like to point out that I ran into the "too much current has been drawn on VDD" error when interfacing a PIC16F1823 to a CP2102 USB/Serial converter that I bought off the 'bay. With a 1K resistor on the PIC's Tx and a 10K on the Rx, it seems to be working. I haven't tried other values for the resistors, but I do know that 10K on the PIC's Tx breaks transmission and 1K on the PIC's Rx isn't enough to get rid of the "too much current" error. I'm not sure what's going on in the CP2102 circuit, but apparently some PIC's need the resistance to keep the current down when using these Serial/USB translators.

This is programming it with a Pickit3 in Mplab IDE v1.95 and XC8 compiler.

Hopefully this info will be helpful to somebody else down the road.
 
Top