arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 it can be set like this : in sensor send, get ack, go sleep 100ms, after that go receive for 20-40ms. on RX side you set sending mode(probably using other nrf module if you have more then one sensors, set retransmit to minimum, start transmit.that way nrf will do transmition when remote sensor go online for receive. Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 gotcha... Just be aware, 250Kbps speed doesn't work with the auto-ack retransmit stuff, I found that out by experimentation and analysis with a logic analyzer months ago. So keep that sort of scheme running at 1 or 2Mbps (with comparably reduced range). Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 bug: code without radio.begin(); radio.setTXaddress((void*)txaddr); not work after radio.deepsleep(); so it not work like you say(auto-wakeup on flush) Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Wait, you're running the radio.begin() and radio.setTXaddress(....) stuff in setup() right? Those belong in setup() and not in loop(). Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 see code above. if i do .deepsleep(), after that any flush NOT work. it work ONLY if i do begin again. Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 I see what you mean, post your whole sketch... I don't see your setup() function... Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Wow ok, I think we have another problem here. I just set up a set of those demos on a pair of launchpads with Serial output enabled at 9600bps that periodically kicks out the transceiver state, and on the TX side, what I see is anytime I do serial output, the radio.flush() function hangs indefinitely... Sniffing all the I/O with my logic analyzer, it seems like there's a conflict between Energia's handling of the Serial output (which seems to happen in the background BTW) and the SPI I/O going over the USCI_B port. Periodically when UART characters go out, a mysterious set of 8 clock ticks kick out over the SCLK line (even though the nRF24 CSN line is high). Edit: Found the bug. Energia's USCI ISR handler, used for I2C and for Serial I/O, runs the I2C RX/TX handler when SPI is in use. It should only run this when I2C is in use. Offending section in /Applications/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430/usci_isr_handler.c: __attribute__((interrupt(USCIAB0TX_VECTOR))) void USCIAB0TX_ISR(void) { /* USCI_A0 UART interrupt? */ if (UC0IFG & UCA0TXIFG) uart_tx_isr(); /* USCI_B0 I2C TX RX interrupt. */ if ((UC0IFG & (UCB0TXIFG | UCB0RXIFG)) != 0) i2c_txrx_isr(); } My modified version: __attribute__((interrupt(USCIAB0TX_VECTOR))) void USCIAB0TX_ISR(void) { /* USCI_A0 UART interrupt? */ if (UC0IFG & UCA0TXIFG) uart_tx_isr(); /* USCI_B0 I2C TX RX interrupt. */ if ((UCB0CTL0 & UCMODE_3) == UCMODE_3 && (UC0IFG & (UCB0TXIFG | UCB0RXIFG)) != 0) i2c_txrx_isr(); } *** NOTE *** No changes necessary to the USCIAB0RX_ISR handler, and that function should be kept in place as is. This is only a change to the USCIAB0TX_ISR function. This way the i2c_txrx_isr() crap is only considered if I2C mode is actually enabled, i.e. UCB0CTL UCMODE = 0b11 (3, I2C). This should be pushed up/reported to the Energia devs... There might be other considerations for the EUSCI chips, I didn't look at that code. Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Anyway after modifying the Energia core's usci_isr_handler.c for that, my TX demo works correctly, spitting out serial output while simultaneously forcing the LED on my other launchpad to blink (it's running the RXdemo). Also, my latest GIT commit to the project includes my serial-output-ified version of the examples. Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 no. that is nto bug i reported. i removes serial. okay. here is code: void setup() { //Serial.begin(9600); //Serial.println('1'); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); // MSB-first //Serial.println('2'); radio.begin(); // Defaults 1Mbps, channel 0, max TX power Serial.println(radio.radioState()); radio.setSpeed(1000000); radio.setTXaddress((void*)txaddr); } void loop() { radio.begin(); radio.setTXaddress((void*)txaddr); radio.print(str_on); radio.flush(); // Force transmit (don't wait for any more data) radio.deepsleep(); delay(1000); radio.begin(); radio.setTXaddress((void*)txaddr); radio.print(str_off); radio.flush(); // radio.deepsleep(); delay(1000); } this one is working. this one is NOT working void setup() { //Serial.begin(9600); //Serial.println('1'); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(1); // MSB-first //Serial.println('2'); radio.begin(); // Defaults 1Mbps, channel 0, max TX power Serial.println(radio.radioState()); radio.setSpeed(1000000); radio.setTXaddress((void*)txaddr); } void loop() { radio.print(str_on); radio.flush(); // Force transmit (don't wait for any more data) radio.deepsleep(); delay(1000); radio.print(str_off); radio.flush(); // radio.deepsleep(); delay(1000); } also if i switch to lpm3, after that nrf never start at all. Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 ignore that. it still compile it with serial becuase there is one call to serial not commented. without serial it work ok(but still not work after power saver mode) Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 can you please explain where/how patch serial port? or i just have wait next energia release? Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Ok, so I tried using deepsleep() after flush() and it works for me, including serial output (I have patched my Energia core manually), doing a deepsleep() after flush() I still get my LED blinking once a second on the RX launchpad. To patch it, find the Energia install, look for the "hardware/msp430/cores/msp430" directory... Find "usci_isr_handler.c" Find the section in my post above (http://forum.43oh.com/topic/3237-energia-library-nordic-nrf24l01-library/page-2#entry28498) and add in the "(UCB0CTL0 & UCMODE_3) == UCMODE_3 &&" to the beginning of that if() statement so the i2c_rxtx_isr() only runs if UCMODE = 3. Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 As for LPM3, I'm not sure that'll work right with Energia, because what's waking it up periodically is the WDT ... and that runs off SMCLK, which is disabled in LPM3 mode. You'd have to manually configure Timer_A to run off ACLK, set up the VLOCLK or XT1CLK (for 32.768KHz crystal) yourself, and have a Timer_A ISR that wakes up your chip. Quote Link to post Share on other sites
arheops 0 Posted January 25, 2013 Share Posted January 25, 2013 thanks,will try patch it. yes, i am triing figuring out how to change timer in energia to VLO and after that return it back without power saving it get near 0.9mA,that is too much. ps got 0.50mA by patching wiring.c to start at 8mhz. unfortanly at 2mhz nrf just not work. Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Couple git commits- flush() had a bug where if you ran it while in RX mode, it wouldn't work. Now flush() has been reworked so it detects a present RX mode, backs out of it (remembering whether or not it was in RX mode when flush() was called), then after all the TX business has completed and IRQs fired, it will run enableRX() to re-enter RX mode. Also flush() now checks if the txbuf is zero-length and return immediately (nothing to send). Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.