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

bootup sequence

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

bootup sequence
PostPosted: Tue Aug 09, 2011 10:05 am     Reply with quote

Hi There,

In order to conserve as much startup current as possible, I wanted to manually start my two USARTs.
I declared like this:
Code:

#define BAUDRATE 19200

#use delay(clock=20000000)
#use rs232(baud=0,parity=N,xmit=MCU1_TX,rcv=MCU1_RX,UART1,stream=MCU1, ERRORS)
#use rs232(baud=0,parity=N,xmit=PC_TX,rcv=PC_RX,UART2,bits=8,stream=PC, ERRORS)

and when it's time to start them in my code i do the following:
Code:
  setup_uart(BAUDRATE,MCU1);
  delay_ms(100);
  setup_uart(BAUDRATE,PC);

This however doesn't seem to work, the mcu seems to hang itself up on the first fprintf command after the setup_uart():
Code:
fprintf (PC,"TEST");


Why would that be, any clues? What am I doing wrong?

Thank you!
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 09, 2011 12:15 pm     Reply with quote

Off hand I'd say the (baud=0...) might be the culprit. Perhaps your version of the compiler can't figure out the 'BAUDRATE' = baud code???

What happens if you hardcode the baudrate in the use rs232() functions ?

Off the other hand just how much energy do you figure you save by doing this sequence. Sometimes it's easier (and cheaper) to put a bigger battery in then tweak code !
ckielstra



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

View user's profile Send private message

PostPosted: Tue Aug 09, 2011 12:41 pm     Reply with quote

What is your compiler version?
Which PIC processor?


Like Temtronic wrote I suspect the baud=0 to be the problem. Setup the UARTS with a standard #use RS232 line and then control the UART with:
Code:
setup_uart(0);  // UART off
setup_uart(1);  // UART on
setup_uart(9600);  // alternative 'UART on' which also sets a (new) baudrate


One other problem in your #use rs232 line is that you are defining the pin numbers for Tx and Rx but you also have the 'UART1' and 'UART2' directives. These are mutually exclusive. You should either set the pins, or use the UARTx directive but don't use both as it can lead to undefined behaviour.[/code]
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Tue Aug 09, 2011 4:18 pm     Reply with quote

OK, Well, I guess we figured out another way to cut back enough power. Still using the #use rs232 directives and am looking into removing the pin definitions asap.
Thanks guys for the input!
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