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

Receive Buffer Assistance

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Receive Buffer Assistance
PostPosted: Fri Oct 06, 2006 11:06 am     Reply with quote

Hello All,

I'm porting some code over to use one of Asmallri's UART drivers and have run into a snag. (btw, I purchased his simple SW_UART driver and I am extremely impressed with it. He was extremely helpful in trying to track down a previous bug. I learned a huge amount just by looking at the way he had done things.)

The new driver is so fast it passes through a while(kbhit) statement and keeps on going.

Code:

         while(HW_UART_KBHIT()) {
            i = HW_UART_getcQ();
            buffer[length] = i;
            length++;
         }


So, by the time it fetches the first character and checks the WHILE again the next character hasn't arrived and it exits the loop. I tryed a delay in the loop but that doesn't work.

Any suggestions how to fix this?

Any better ways to deal with receiving a fixed length string?

Thanks,

John
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Fri Oct 06, 2006 11:54 am     Reply with quote

Well if the while loop is inside an interrupt service routine (isr) linked to #rda
it will be called back when the next char arrives. Could it be you don't have the while inside an isr? You need the while loop to exit when there is no pending char so it can give life back to your mainline code.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Fri Oct 06, 2006 12:11 pm     Reply with quote

That makes sense!

No the WHILE isn't in the ISR. This isn't the typical INT_RDA driven serial stuff. Andrew has done a pretty nifty set of drivers for HW and SW serial ports and that's what I'm trying to get ported to. (Unfortunately, it's o'dark thirty in Perth right now so I'm on my own until he gets back to me.) I was hoping to have this solved by that time to save him the hassle.

Your nudge will help me look at his code again and maybe figure what's going on a little better. In the mean time I'm rewriting the receive buffer...

Thanks,

John
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Fri Oct 06, 2006 2:32 pm     Reply with quote

Well serial communications is as old as the wheel. It is pretty much perfected already. I don't see any need to have the wheel re-invented but whatever works for you more power to you. This code you purchased has some issues for you but the best solution seems to be to wait for Australia to wake up and help you. If you decide to switch back to the standard approach this board has addressed many of the possible serial communication issues and more than one person can help you.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sat Oct 07, 2006 7:57 pm     Reply with quote

I found my problem fairly quickly and as usual it was self inflicted.

As a novice, I think my $30 investment for some professionally written code was minor. I learned a bunch and got a variety of new ideas of how to deal with every aspect of CCS and C programming. My only mistake was assuming the problem was with the code that I purchased and not my own doing.

John
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