|
|
View previous topic :: View next topic |
Author |
Message |
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
RN2903 Wake up |
Posted: Wed Mar 21, 2018 4:30 pm |
|
|
Hi I need Wake up this module, but I can not get...
The manual say its necessary a "break condition" how I can do?
http://ww1.microchip.com/downloads/en/DeviceDoc/40001811A.pdf
for sleep module
Code: | fprintf(lora,"sys sleep 40000\r\n"); // // Enter sleep mode for 40 seconds
|
for wake up
Code: | output_low(TXD_Lora); // Start break signal on MCU TX pin
delay_ms(1000);;
output_high(TXD_Lora); // Start break signal on MCU TX pin
fprintf(lora, 0x55); // Send magic break character (auto bauding) |
But not work |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Mar 21, 2018 4:38 pm |
|
|
This would not create a break condition because the uart is mapped to the serial port. To use this mechanism you would need to close the serial port, send your break, then open the serial port.
Alternatively, you could wake the module via toggling the reset line. This is the mechanism I use. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Wed Mar 21, 2018 5:07 pm |
|
|
asmallri wrote: | This would not create a break condition because the uart is mapped to the serial port. To use this mechanism you would need to close the serial port, send your break, then open the serial port.
Alternatively, you could wake the module via toggling the reset line. This is the mechanism I use. |
Thanks, I use that PIN RESET, but I did many PCB and not put that wire...because I need wake up and not Reset |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Mar 21, 2018 6:38 pm |
|
|
You need the CCS equivalent of this:
Code: |
void wakeUP_RN2483() {
Serial1.end();
pinMode(PIN_SERIAL1_TX, OUTPUT);
digitalWrite(PIN_SERIAL1_TX, LOW);
delay(5);
digitalWrite(PIN_SERIAL1_TX, HIGH);
Serial1.begin(57600);
Serial1.write(0x55);
} |
_________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Wed Mar 21, 2018 11:46 pm |
|
|
asmallri wrote: | You need the CCS equivalent of this:
Code: |
void wakeUP_RN2483() {
Serial1.end();
pinMode(PIN_SERIAL1_TX, OUTPUT);
digitalWrite(PIN_SERIAL1_TX, LOW);
delay(5);
digitalWrite(PIN_SERIAL1_TX, HIGH);
Serial1.begin(57600);
Serial1.write(0x55);
} |
|
Yes I tried use this
Code: | #include <18F4550.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP, CPUDIV1
#use delay(clock=4000000)
#define BAUDRATE 9600
#define TX_PIN PIN_C6
#define RX_PIN PIN_C7
#use rs232(baud=BAUDRATE, xmit=TX_PIN, rcv=RX_PIN, ERRORS)
void send_break(int8 time_ms)
{
// Disable the UART and send a Break
// for the specified time.
setup_uart(FALSE);
output_low(TX_PIN);
delay_ms(time_ms);
// Re-enable the UART.
setup_uart(TRUE);
set_uart_speed(BAUDRATE);
}
//======================================
void main(void)
{
int8 c;
printf("Start:\n\r");
send_break(20);
while(1)
{
c = getc(); // Get a char from the PC
putc(c); // Send it back to the PC
}
} |
But no work, I have this
#BIT TX_S = 0xF94.6 // Pin direction mapped to TRISC.6
#BIT RX_S = 0xF94.7 // Pin direction mapped to TRISC.7
Code: | #define BAUDRATE 57600
#define TXD_Lora PIN_C6 // TXD_Lora
#define RXD_Lora PIN_C7 // RX_Lora
#use rs232(baud=BAUDRATE,xmit=TXD_Lora,rcv=RXD_Lora,bits=8,parity=N,ERRORS,stream=lora) // Modulo RN2903
//!#use rs232(baud=57600,xmit=PIN_c6,rcv=PIN_c7,bits=8,parity=N,ERRORS,stream=lora) // Modulo RN2903
#use rs232(baud=9600,xmit=PIN_b6,rcv=PIN_b7,bits=8,parity=N,ERRORS,stream=debug) // Puerto DEBUG
setup_uart(FALSE,lora); //Serial1.end();
TX_S=0; //pinMode(PIN_SERIAL1_TX, OUTPUT);
output_low(TXD_Lora); //digitalWrite(PIN_SERIAL1_TX, LOW);
delay_ms(100);
output_high(TXD_Lora); //digitalWrite(PIN_SERIAL1_TX, HIGH);
set_uart_speed(BAUDRATE,lora); //Serial1.begin(57600);
fprintf(lora,0x55); //Serial1.write(0x55);
|
So I don know how "disable" de lora port
There is other code
but how write in CCS?
Code: | void RNsleep(void)
{
UART_Write_Text("sys sleep 400000000");
delayXs(1);
}
void RNwakeUp(void)
{
while(!TRMT);
TXREG = 0x00;
while(!TRMT);
TXREG = 0x55;
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Thu Mar 22, 2018 1:23 am |
|
|
Code: |
#include <18F4550.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP, CPUDIV1
#use delay(clock=4000000)
#define BAUDRATE 9600
#define TX_PIN PIN_C6
#define RX_PIN PIN_C7
#use rs232(baud=BAUDRATE, xmit=TX_PIN, rcv=RX_PIN, ERRORS)
void send_break(int16 time_ms) //note int16
{
// Disable the UART and send a Break
// for the specified time.
setup_uart(FALSE);
output_low(TX_PIN);
delay_ms(time_ms);
// Re-enable the UART. - sending 'non zero', enables and sets the
//baud rate
setup_uart(BAUDRATE);
putc(0x55); //The character after the break _[u]must[/u]_ be 0x55
}
//======================================
void main(void)
{
int8 c;
delay_ms(500); //give time for other things to wake
printf("Start:\n\r");
send_break(20);
while(TRUE)
{
c = getc(); // Get a char from the PC
putc(c); // Send it back to the PC
}
}
|
What you have would work, except you are missing the 0x55 character that must follow the break. Also you don't need to set the baud rate separately. The setup_uart command can do this in one operation.
Note also the delay. Any module like this (running firmware), takes time to boot. Most need perhaps 100mSec, before they can accept commands after power-on. I can't see anything in the data sheet saying how long it does need, but 'history' says a delay before trying to change the baud rate is probably sensible.... |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 347
|
|
Posted: Thu Mar 22, 2018 2:56 am |
|
|
Hello,
I'm also using RN2483 Lora modem in peer to peer mode with hardware reset pin without problem.
Best Regards! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Thu Mar 22, 2018 12:05 pm |
|
|
Ttelmah wrote: |
Note also the delay. Any module like this (running firmware), takes time to boot. Most need perhaps 100mSec, before they can accept commands after power-on. I can't see anything in the data sheet saying how long it does need, but 'history' says a delay before trying to change the baud rate is probably sensible.... |
FYI, I tested this with current generation RN2903A modules. It consistently takes 4.6ms to be ready from a software reset or hardware reset. I chose this method over the wake / break sequence because I thought it was cleaner. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Thu Mar 22, 2018 12:50 pm |
|
|
Useful data. I'd say to use 10mSec to be safe then. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Thu Mar 22, 2018 2:42 pm |
|
|
Thanks to everyone.
I did this:
Code: | #include <18LF26K22.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#use delay(clock=4000000)
#define BAUDRATE 9600
#define TX_PIN PIN_C6
#define RX_PIN PIN_C7
#use rs232(baud=BAUDRATE, xmit=TX_PIN, rcv=RX_PIN, ERRORS)
void blink_led(PIN,int1 time_up,int time_down );
void send_break(int16 time_ms){
// Disable the UART and send a Break for the specified time.
setup_uart(FALSE);
output_low(TX_PIN);
delay_ms(time_ms);
// Re-enable the UART. - sending 'non zero', enables and sets the baud rate
setup_uart(BAUDRATE);
putc(0x55); //The character after the break _[u]must[/u]_ be 0x55
}
//======================================
void main(void) {
char c;
delay_ms(500);
while(TRUE){
c=0x00;
printf("sys sleep 20000\r\n");
delay_ms(4000);
send_break(200);
printf("sys get ver\r\n");
delay_ms(200);
c = getc();
if (c=="R") blink_led(pin_c5,20,50);
}
}
//******* Blink LED *********************
void blink_led(PIN,int1 time_up,int time_down ){
output_high(PIN); delay_ms(time_up);
output_low(PIN); delay_ms(time_down);
} |
but not work... the module not wake up
I not wanted use the PIN RESET... but to end I have do it.
What is the diference if I reset the module to Wake up?...
maybe its better RESET |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Thu Mar 22, 2018 3:52 pm |
|
|
Does your PSU meet the supply rise time requirements for the unit?. If not, the chip may not be resetting properly on power on. Remember the chip has to have successfully booted, before you can use the 'break' command sequence. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Tue Aug 07, 2018 11:18 pm |
|
|
I am again here.... I saw this example from microchip, so how I do on CCS?
please
Code: | void moduleResync(void)
{
// First send wake up / restart autobaud
TXSTAbits.TXEN = 0;
EUSART_TX_LAT = 0;
_delayms(10);
TXSTAbits.TXEN = 1;
_delayms(5);
// Now send autobaud detect character
TXREG = 0x55;
while (TXSTAbits.TRMT == 0)
{};
// Now send a command to be ignored
sendCommand("z");
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Wed Aug 08, 2018 1:07 am |
|
|
Er something like:
Code: |
setup_uart(FALSE); //turn off the UART
output_low(TX_PIN); //select to suit your UART
delay_ms(10);
setup_UART(TRUE); //turn UART back on
delay_ms(5);
putc(0x55);
|
Then you would need whatever the 'sendcommand' code has in it.
The autobaud here is for the remote device not the PIC, so it doesn't have to do anything except send a break (which is what turning off the UART, and dropping the TX pin does), and then send the sync character (0x55) to the remote device. |
|
|
|
|
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
|