I purchased a few pair of these 433MHz RF Tx/Rx modules and am working on getting some basic code functionality on two AVRs with intermittent success. I've gotten the modules to work near flawlessly with two Arduino's using the RCSwitch.h library, so I'm assuming my issue lies somewhere in my code.
The setup takes a button input on the TX MCU (mega328) and toggles a local LED. It also transmits a 4-byte packet to the RX MCU (tiny2313). The packet consists of a sync , address, command and checksum byte precluded by a stream of 25 0xAA bytes to get the RX module 'tuned in'. The RX MCU then turns on/off a remote LED based on the command sent. The 4-byte packet is Manchester encoded before sent (which technically turns it into 8 encoded bytes) and sent/received via USART.
I've used a logic analyzer to test both the transmitted and received data stream, and the data being sent is identical to the data received. I don't have an example of the analyzer's output saved, nor the setup with me at the moment, but I can set it up and post an image of it tomorrow. However, assuming that it is sending and receiving the data properly, the issue must be with my RX code.
The project consists of 5 files:
Now before I start getting hated on, I know I shouldn't be doing all the Rx routines from within the ISR. However, since the only function of the RX MCU is to wait for data, process it then wait again, I didn't see the harm in it while testing. Once I get it all figured out, I'll pull it out of the ISR...assuming the problem isn't because it's in the ISR
However, it has worked intermittently, so I doubt that's the root cause.
I'm sure there's a bunch of info I'm missing, so please just ask and I'll gladly provide anything I'm missing. I'll also try to post images of the data streams in the morning as well. But I think this is enough to at least get some initial feedback. Thanks in advance for any help, it's greatly appreciated!
The setup takes a button input on the TX MCU (mega328) and toggles a local LED. It also transmits a 4-byte packet to the RX MCU (tiny2313). The packet consists of a sync , address, command and checksum byte precluded by a stream of 25 0xAA bytes to get the RX module 'tuned in'. The RX MCU then turns on/off a remote LED based on the command sent. The 4-byte packet is Manchester encoded before sent (which technically turns it into 8 encoded bytes) and sent/received via USART.
I've used a logic analyzer to test both the transmitted and received data stream, and the data being sent is identical to the data received. I don't have an example of the analyzer's output saved, nor the setup with me at the moment, but I can set it up and post an image of it tomorrow. However, assuming that it is sending and receiving the data properly, the issue must be with my RX code.
The project consists of 5 files:
- ATmega328Tx.c - Main program for the mega328
- manchesterTX-mega328.h - header file with the USART send routines
- ATtiny2313Rx.c - Main program for the tiny2313
- manchesterRX-tiny2313.h - header file with the USART receive routines
- manchesterGlobal.h - common header file for both Tx and Rx programs
Now before I start getting hated on, I know I shouldn't be doing all the Rx routines from within the ISR. However, since the only function of the RX MCU is to wait for data, process it then wait again, I didn't see the harm in it while testing. Once I get it all figured out, I'll pull it out of the ISR...assuming the problem isn't because it's in the ISR
I'm sure there's a bunch of info I'm missing, so please just ask and I'll gladly provide anything I'm missing. I'll also try to post images of the data streams in the morning as well. But I think this is enough to at least get some initial feedback. Thanks in advance for any help, it's greatly appreciated!
Attachments
-
26.9 KB Views: 28
-
23 KB Views: 19
-
16.3 KB Views: 17
-
34.2 KB Views: 21
-
22.8 KB Views: 21