More Problems with RS232 and PIC18F25K22
Posted: Mon Mar 18, 2013 4:52 am
I seem to have the same problem with as a previous poster with RS232 on an 18F25K22, I checked my FCD file and it is the same as the new one provided in that post. I can transmit but not receive. Simulation using VNet works fine in both directions. I also can prove that data is getting to the PIC, the baud rate and other serial setting are fine as I can transmit strings with no problems. Setting the RS232 macro to echo returns various corrupt chars suggesting a framing or baud error but I can't find one. My logic analyser says the baud rate is spot on.
Incoming serial has a variety of problems depending on how I try to capture it.
Using ReceiveRS232String I get only one character of a 60-70 char string. And even that is not correct.
Looping round ReceiveRS232Char and converting each char to a string and concatenating, I can sometimes get the first 20 or so chars correctly then the remainder becomes 0x40 or 0x80, with a few apparently random chars at the end.
Looping round ReceiveRS232Char and writing the returned values to an integer array (avoiding using strings) I get a stream of 0x40 or 0x80 (occasionally other chars).
Tweaking various things I sometimes I get nothing at all. Sometimes it seems like the RX interupt doesn't fire at all (don't know what changes that causes this, most of time the interrupt is OK). I've also tried polling instead of using the interrupt, same problem. I'm running the PIC at 8Mhz and comms at 9600 which doesn't seem too onerous to me. I've tried hardware flow control with no success. I am using a PICkit 3 and Flowkit to program and debug. I wondered if maybe the debug was slowing things down but, as much as I can test without the debugger, there still seems to be a problem.
I am using the Char Receive type of Int (extended data) with 8bit data because 0xFF is a legitimate value in the serial data I'm trying to read so I can't use that as timeout return. It did seem to work better with Byte receive type but this might have been my imagination. I've reached the end of my creativity in thinking up new tests to try.
In my FCF, attached, there is a macro, UARTC0_RX_INT, that have the three different serial reading strategies described above. I just change the switch to try any of them. There are also a lot of other macros disabled or bypassed to simplify the code. I've tried various options in the chip configuration that might have some bearing on the serial port but I am a bit in the dark on most of those.
Also, probably another issue, but breakpoints don't seem to work when using the FlowKit debugger.
Hopefully someone can spot an issue in my code or have had similar experience.
Thanks.
Incoming serial has a variety of problems depending on how I try to capture it.
Using ReceiveRS232String I get only one character of a 60-70 char string. And even that is not correct.
Looping round ReceiveRS232Char and converting each char to a string and concatenating, I can sometimes get the first 20 or so chars correctly then the remainder becomes 0x40 or 0x80, with a few apparently random chars at the end.
Looping round ReceiveRS232Char and writing the returned values to an integer array (avoiding using strings) I get a stream of 0x40 or 0x80 (occasionally other chars).
Tweaking various things I sometimes I get nothing at all. Sometimes it seems like the RX interupt doesn't fire at all (don't know what changes that causes this, most of time the interrupt is OK). I've also tried polling instead of using the interrupt, same problem. I'm running the PIC at 8Mhz and comms at 9600 which doesn't seem too onerous to me. I've tried hardware flow control with no success. I am using a PICkit 3 and Flowkit to program and debug. I wondered if maybe the debug was slowing things down but, as much as I can test without the debugger, there still seems to be a problem.
I am using the Char Receive type of Int (extended data) with 8bit data because 0xFF is a legitimate value in the serial data I'm trying to read so I can't use that as timeout return. It did seem to work better with Byte receive type but this might have been my imagination. I've reached the end of my creativity in thinking up new tests to try.
In my FCF, attached, there is a macro, UARTC0_RX_INT, that have the three different serial reading strategies described above. I just change the switch to try any of them. There are also a lot of other macros disabled or bypassed to simplify the code. I've tried various options in the chip configuration that might have some bearing on the serial port but I am a bit in the dark on most of those.
Also, probably another issue, but breakpoints don't seem to work when using the FlowKit debugger.
Hopefully someone can spot an issue in my code or have had similar experience.
Thanks.