|
|
View previous topic :: View next topic |
Author |
Message |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
bootup sequence |
Posted: Tue Aug 09, 2011 10:05 am |
|
|
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: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Aug 09, 2011 12:15 pm |
|
|
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
|
|
Posted: Tue Aug 09, 2011 12:41 pm |
|
|
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
|
|
Posted: Tue Aug 09, 2011 4:18 pm |
|
|
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! |
|
|
|
|
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
|