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

Sending a Break Sequence

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



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

Sending a Break Sequence
PostPosted: Wed Oct 05, 2011 8:45 am     Reply with quote

I have a PIC16F1825 with hardware uart.

My Trimble GPS board will send me its hardware serial setup and other information such as model no. if I send it a 250ms min. duration break sequence. Once I do this, then the board will always respond at 9600 baud with the current setup information.

I want to do this at power up once. What is the best way to do this?

Here is a snippet of what I tried so far, but get no response. Should I force the TX pin low for 300ms at power up then setup the hardware uart to 9600? I will eventually use RDA interrupt but just want a working test for now.

Code:

output_high(pin_c4);
delay_ms(1000);
output_low(pin_c4);
delay_ms(300);
output_high(pin_c4);

#use rs232(baud=9600,parity=N,xmit=PIN_C4,rcv=PIN_C5,bits=8,stream=uar1,errors)
while (1){
   if (kbhit(uar1)){
      chr = fgetc(uar1);
      buffer[pnt] = chr;
      if (chr == 3) goto dn;//ETX (end of text)
      if (pnt < 100) pnt++;
   }
}
dn:
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 05, 2011 11:21 am     Reply with quote

This thread discusses ways to send an extra long break sequence:
http://www.ccsinfo.com/forum/viewtopic.php?t=42857
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

PostPosted: Fri Oct 07, 2011 8:33 am     Reply with quote

Thanks, I looked at that thread.

It must be because the chip is a 16F1825 but I am getting a Undefined Identifier when I try to use setup_uart(false) with V4.124
Ttelmah



Joined: 11 Mar 2010
Posts: 19491

View user's profile Send private message

PostPosted: Fri Oct 07, 2011 9:23 am     Reply with quote

Reason for that, is that the compiler doesn't know you want to use the hardware UART. You need to use:
Code:

#use rs232(baud=0,parity=N,UART1,bits=8,stream=PORT1)
 //Note baud=0, and selected UART1, not pins

void main() {

   setup_comparator(NC_NC_NC_NC);
   output_low(PIN_C4);
   delay_ms(100); //100mSec break
   output_high(PIN_C4);
   setup_uart(9600); //Enable UART
   fprintf(PORT1,"Test message \n\r");
   setup_uart(FALSE);
   output_low(PIN_C4);
   delay_ms(100); //100mSec break
   output_high(PIN_C4);
   setup_uart(9600); //Enable UART
   fprintf(PORT1,"Test message #2 \n\r");

   do {
   
   } while(TRUE);
}

Using 'BAUD=0', leaves the UART unconfigured on boot, and it is turned on, when you set a baud rate. Using 'UART1', tells the compiler to use the hardware UART, not implement a software UART. Though C4, and C5, are the default pins for RX/TX, the compiler doesn't 'know' that the UART is on these pins, so implements a software UART.....
This should send two breaks, with the two test messages.

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