I have a PIC project that I'm working on which involves making use of UART facilities of PIC16F628A to receive data from a GPS receiver (Holux GPSlim236 - *no* bluetooth).
The problem I'm facing right now seems to be that my PIC is receiving corrupt data. Here are the steps I've taken so far to figure out the cause:
1. Wrote a test program for the PIC to continuously send out a "AB" pattern. Connected the TX pin to an erricsson data cable (uses SIPEX SP232ACN chip level converter) and that to RS232 port on my PC and I could see the "AB" pattern on my linux serial terminal. Not a single gap or missing character!
1. Now, wrote a different test program for the PIC to send out any data it receive immediately. Connected the pic to RS232 port on my desktop through the same cable. If everything was to work properly, this setup would be same as a null modem. Not quite. Sometimes I got what I typed, most of the time I got garbage. I also set up a little debugging LED to light up if there was any error. It turns out Framing Errors occur right after the first few characters (sometimes the first).
Initially I thought the different voltage levels (TTL for the cable, CMOS for the PIC) was the problem, but after consulting the PIC's datasheet, found out that the Schmitt Trigger on the RX pin works from 0.8v to 5.0v for high signal. 3v of TTL falls in that range. Or am I wrong to assume this is how Schmitt Triggers work?
All I can deduce here is that there is some signal level/noise issue here. Yet again, connecting the GPS through the same cable works flawlessly.
So my questions:
1. Do I need to convert the TTL level to drive my RX pin?
2. If not, could you please give me a lead on how to go about solving this problem? (I've been trying to figure this out for over 2 days now)
Here're some info that might help you help me:
- using an external 20Mhz Crystal
- UART speed is 38400
- I have lots of programming background, not much electronics
If you think there is something might be wrong with the code, I'll post the code too.
Appreciate it if you could give me some advice on this.
I *have* read the sticky post for newcomers
The problem I'm facing right now seems to be that my PIC is receiving corrupt data. Here are the steps I've taken so far to figure out the cause:
1. Wrote a test program for the PIC to continuously send out a "AB" pattern. Connected the TX pin to an erricsson data cable (uses SIPEX SP232ACN chip level converter) and that to RS232 port on my PC and I could see the "AB" pattern on my linux serial terminal. Not a single gap or missing character!
1. Now, wrote a different test program for the PIC to send out any data it receive immediately. Connected the pic to RS232 port on my desktop through the same cable. If everything was to work properly, this setup would be same as a null modem. Not quite. Sometimes I got what I typed, most of the time I got garbage. I also set up a little debugging LED to light up if there was any error. It turns out Framing Errors occur right after the first few characters (sometimes the first).
Initially I thought the different voltage levels (TTL for the cable, CMOS for the PIC) was the problem, but after consulting the PIC's datasheet, found out that the Schmitt Trigger on the RX pin works from 0.8v to 5.0v for high signal. 3v of TTL falls in that range. Or am I wrong to assume this is how Schmitt Triggers work?
All I can deduce here is that there is some signal level/noise issue here. Yet again, connecting the GPS through the same cable works flawlessly.
So my questions:
1. Do I need to convert the TTL level to drive my RX pin?
2. If not, could you please give me a lead on how to go about solving this problem? (I've been trying to figure this out for over 2 days now)
Here're some info that might help you help me:
- using an external 20Mhz Crystal
- UART speed is 38400
- I have lots of programming background, not much electronics
If you think there is something might be wrong with the code, I'll post the code too.
Appreciate it if you could give me some advice on this.
I *have* read the sticky post for newcomers