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 support@ccsinfo.com

Sending 2 bytes without waiting

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








Sending 2 bytes without waiting
PostPosted: Thu Sep 24, 2009 11:28 am     Reply with quote

Hi,
I am using a PIC18F2520.

These lines of code are called every 250ms.

Code:
putc(OutByte1);
putc(OutByte2);


I don't want the PIC sitting between these two statements waiting for the first one to complete. As I understand the datasheet TSR will be empty before the first putc.
The first putc will load the TXREG register with OutByte1, which will "instantly" move to TSR Register and allow OutByte2 to then load into TXREG. Effectively a one byte hardware buffer? How many cycles will these two lines take?

1 to load TXREG with OutByte1 (MOVFF command?)
1 to move TXREG to TSR
1 to load TXREG with OutByte2 (MOVFF command?)

In my case only two bytes are ever sent so I don't think I need to implement a TXIF interrupt?

I can't afford for a delay between these two putcs!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 24, 2009 12:25 pm     Reply with quote

Just use the interrupt. There is seldom, if any, reason not to.
Code:
C:\Program Files\PICC\Examples\EX_STISR.C
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Sep 24, 2009 1:38 pm     Reply with quote

Quote:
In my case only two bytes are ever sent so I don't think I need to implement a TXIF interrupt?
Yes, in this special the direct method means less overhead.
Ttelmah
Guest







PostPosted: Thu Sep 24, 2009 2:49 pm     Reply with quote

Provided the hardware buffer is empty, and the shift register is empty, when you start, the two putc instructions won't wait.
The code used by CCS, tests the buffer full bit, and only waits when sending a character, if the hardware can't take it.

Best Wishes
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