View previous topic :: View next topic |
Author |
Message |
david smith Guest
|
too many chars breaks ser-in code |
Posted: Tue Nov 26, 2002 4:48 pm |
|
|
My Ser-in routine looks for exactly 4 chars (a float).
I use the timed_putc() from manual. It works...
if I type <4 chars, 4 chars, 5 chars.
If I type a whole slew of chars, it then ignores the routine.
Why? How to avoid problems for anomalous input?
PIC 'F873, Compiler v3.091, 9600Bd, using HW UART
Any thoughts?
int main() { //
...
while(1) {
if( kbhit()==1 ) {
disable_interrupts(INT_TIMER2);
getPulseRate(1);
enable_interrupts(INT_TIMER2);
}
}
}
//--------
void getPulseRate(n) {
for(i=0; i<4; i++) {
*(&x+i) = timed_getc();
}
...
}
//--------
int1 timeout_error;
char timed_getc() {
int16 timeout;
timeout_error=FALSE;
timeout=0;
while(!kbhit() && (++timeout<50000)) delay_us(10);
if(kbhit()) return(getc());
else {
timeout_error=TRUE;
return(0);
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 9466 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: too many chars breaks ser-in code |
Posted: Tue Nov 26, 2002 6:16 pm |
|
|
:=My Ser-in routine looks for exactly 4 chars (a float).
:=I use the timed_putc() from manual. It works...
:=if I type <4 chars, 4 chars, 5 chars.
:=If I type a whole slew of chars, it then ignores the routine.
:=
:=Why? How to avoid problems for anomalous input?
:=PIC 'F873, Compiler v3.091, 9600Bd, using HW UART
:=Any thoughts?
-----------------------------------------------------
I'm not sure why you're doing it this way. Why not use
an interrupt-driven receive fifo ? Then in the main loop,
poll the variable that contains the number of received chars.
When it has 4 or more, then pull out the latest 4 chars and
do something with them. CCS has an example of a receive fifo
in the EX_SISR.C file. Look for it this folder:
C:\Program Files\Picc\Examples
___________________________
This message was ported from CCS's old forum
Original Post ID: 9470 |
|
|
david smith Guest
|
Re: too many chars breaks ser-in code |
Posted: Tue Nov 26, 2002 7:14 pm |
|
|
:=:=Why?
I believe your suggestion is a better way; I will try it.
My main program is interrupt driven. While it's in the RDA interrupt, will it ignore TMR interrupts? I still don't see why my existing code fails.
Are you available to discuss this or related items as a consultant? Thanks again for your help.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9476 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: too many chars breaks ser-in code |
Posted: Wed Nov 27, 2002 1:46 am |
|
|
I think you sent me a private message recently.
Unfortunately, I'm unable to read it. If I login,
it shows me that I have 11 messages. But I can only
see three of them, and they're old ones. So the
forum software is broken. I think Sherpa Doug has
found the same thing.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9490 |
|
|
david smith Guest
|
Re: too many chars :msg |
Posted: Wed Nov 27, 2002 10:58 am |
|
|
:=private message error.
I can be reached at david@ninetrees.com or 707-462-0990
___________________________
This message was ported from CCS's old forum
Original Post ID: 9514 |
|
|
|