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

Two Hardware UARTs

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







Two Hardware UARTs
PostPosted: Wed Aug 01, 2007 2:06 am     Reply with quote

Hi,
I need to use two UARTs in my application. I am using PIC18F87J10 which has 2 UARTs.

I have used the following in my code.
#USE RS232(stream=UART1,BAUD=9600, XMIT=PIN_C6,RCV=PIN_C7)
#USE RS232(stream=UART2,BAUD=4800,XMIT=PIN_G1,RCV=PIN_G2)


Both the UARTs are working. I think UART1 is implemented as Hardware UART but UART2 is implemented as software. (no registers of UART2 is initialized)

How to have two hardware UARTs implemented and what is the directive for specific UART( 1 or 2) Tx & Rx


Thanks in advance.

Best Regards
Murali
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 2:40 am     Reply with quote

Quote:
what is the directive for specific UART( 1 or 2) Tx & Rx
Pass the stream you want to access as a parameter to the fputc() and fgetc() functions. Give the streams more meaningful names than UART1 and UART2.

The functions getc/putc don't have a stream identifier and default to STDIN. This might be the reason why you don't see code generated for the second stream.

I also would add the ERRORS directive to the RS232 declaration to prevent the UART from stalling in error situations.

Code:
#USE RS232(stream=PC,  BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)
#USE RS232(stream=GPS, BAUD=4800, XMIT=PIN_G1, RCV=PIN_G2, ERRORS)

void main()
{
  int8 data;

  // Copy all data received from the GPS device to the PC.
  while(TRUE)
  {
    data = fgetc(GPS);
    fputc(data, PC);
  }
}


In case the problem persists, what is your compiler version number?
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