there is also this define
DEFINE HSER_CLROERR 1
That I didn't have in my program. Does it matter where the define goes? If I'm understanding the manual correctly, I shouldn't have to use this any longer? Also, didn't see it mentioned in the manual but will the define clear RCSTA1 and RCSTA2?there is also this define
DEFINE HSER_CLROERR 1
It still won't help my original problem but I'll try lowering the baud rate and see if that helps. If not, I guess flow control is needed.Code:IF RCSTA1.1 = 1 THEN RCSTA1.4 = 0 RCSTA1.4 = 1 DAT_IN1 = RCREG1 IF PIR1.5 = 1 THEN DAT_IN1 = RCREG1 ENDIF
no defines can go anywhere but for readability most keep them altogether and before the main code beginsDoes it matter where the define goes?
you have not specified the version of pbp used it may mattter
DEFINE HSER_CLROERR 1 is definitely a pbp3 define I'm not sure if it applies to pbp2.xx maybe someone else can verify or maybe even rtfm , my pbp2.6 book has been misplaced (again)
Hi,
As far as I know DEFINE HSER_CLROERR 1 (for the second USART it's DEFINE HSER2_CLROERR 1) is available in PBP2.x as well. But, remember that it only "works" when you're actually using HSERIN, if you "drive" the USART manually (like when you do DAT_IN1 = RCREG1) it won't do anything and you'd need to check/clear the overrun flag manually. It all it does is clear the overrun error flag (if set), it won't do anything to actually prevent the overrun condition in first place.
The main issue here is most likely the overall structure of the program. The data needs to be read from the USART buffer before the next byte comes in, the "best" way to handle this (if you don't know when data is about to come in) is usually to use interrupts. I don't know how you're handling it in your program (I may have missed it).
/Henrik.
Overruns aren't really a problem, except when that condition locks up the device. More importantly, you pointed out something I never caught onto. So there is a HSER@2_CLOERR 1 define.As far as I know DEFINE HSER_CLROERR 1 (for the second USART it's DEFINE HSER2_CLROERR 1) is available in PBP2.x as well. But, remember that it only "works" when you're actually using HSERIN, if you "drive" the USART manually (like when you do DAT_IN1 = RCREG1) it won't do anything and you'd need to check/clear the overrun flag manually. It all it does is clear the overrun error flag (if set), it won't do anything to actually prevent the overrun condition in first place.
I use HSERIN/HSERIN2 to get all data and I use interrupts to get it. If I understand your post correctly, I can remove this:The main issue here is most likely the overall structure of the program. The data needs to be read from the USART buffer before the next byte comes in, the "best" way to handle this (if you don't know when data is about to come in) is usually to use interrupts. I don't know how you're handling it in your program (I may have missed it).And just use this:Code:IF RCSTA1.1 = 1 THEN RCSTA1.4 = 0 RCSTA1.4 = 1 DAT_IN1 = RCREG1 IF PIR1.5 = 1 THEN DAT_IN1 = RCREG1 ENDIFIs that correct?Code:DEFINE HSER_CLROERR 1
Hi Christopher,
Yes I believe that's correct. I Think what that define does is add code "in front" of the actual HSERIN code so that it checks the overrun flag and, if set, takes care of it.
/Henrik.
Bookmarks