CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

too many chars breaks ser-in code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
david smith
Guest







too many chars breaks ser-in code
PostPosted: Tue Nov 26, 2002 4:48 pm     Reply with quote

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

View user's profile Send private message

Re: too many chars breaks ser-in code
PostPosted: Tue Nov 26, 2002 6:16 pm     Reply with quote

:=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
PostPosted: Tue Nov 26, 2002 7:14 pm     Reply with quote

:=:=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

View user's profile Send private message

Re: too many chars breaks ser-in code
PostPosted: Wed Nov 27, 2002 1:46 am     Reply with quote

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
PostPosted: Wed Nov 27, 2002 10:58 am     Reply with quote

:=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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group