View previous topic :: View next topic |
Author |
Message |
julian Guest
|
rx and tx dont tied down |
Posted: Mon Feb 16, 2009 1:36 pm |
|
|
Hi,
Im using eusart of a 18f4520, when my process finishes i need to tied down the RX and TX pins, so I use output_low(PIN_C6); and output_low(PIN_C7); but it doesnt work, what can i do?
Thanks |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Mon Feb 16, 2009 1:56 pm |
|
|
I would expect you will first have to disable the EUSART before you "take over" the pins to control them...
setup_uart(false);
This "disconnects" the EUSART so you can control the I/O pins.
Of course you will have to turn it back on when you get ready to use it again. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Feb 16, 2009 2:41 pm |
|
|
Note that low is not the usual idle state for serial pins. If the UART is still active when you pull the serial pin low it will see that as a Start bit and clock in a garbage character. You are doing something unusual, so it may take a bit more typing than the usual. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
julian Guest
|
rx and tx dont tied down |
Posted: Mon Feb 16, 2009 4:36 pm |
|
|
Thank you dyeatman and SherpaDoug .
Problem solved. I use set_uart(FALSE) like dyeatman say and now my program works well
|
|
|
julian Guest
|
rx and tx dont tied down |
Posted: Tue Feb 17, 2009 6:30 pm |
|
|
Using setup_uart(FALSE); bring another problem, now my mcu doesnt wake up, this is the code I use at the end of my program
Code: | setup_uart(FALSE);
output_c(0x00);
output_d(0x00);
delay_ms(2000);
output_low(RELAY);
delay_ms(500);
ext_int_edge(2, H_TO_L);
enable_interrupts(INT_EXT2);
clear_interrupt(INT_EXT2);
enable_interrupts(GLOBAL); |
I tried this
Code: | //setup_uart(FALSE);
#asm ASIS
BCF 0x0FAB.7
BCF 0x0FAB.4
#endasm
//delay_ms(100);
output_c(0x00);
output_d(0x00);
//delay_ms(2000);
output_low(RELAY);
// delay_ms(500);
ext_int_edge(2, H_TO_L);
enable_interrupts(INT_EXT2);
clear_interrupt(INT_EXT2);
enable_interrupts(GLOBAL);
sleep(); |
yesterday without setup_uart(FALSE); mcu wake up
Thanks in advance |
|
|
|