Hello,
I am using the CC112x module to listen to a device generating a custom packet structure that varies from 50 bytes to 128 bytes in length. The length field is always at a 3 byte offset from the end of the sync word and hence I cannot configure PKT_CFG0 to be in variable length mode. The way I plan to implement this is to start the receiver in Infinite packet length mode and read the RxFIFO for the first 3 bytes and once I obtain the length of the packet switch it to fixed length mode. My questions are:
(i) is this possible? Can I reconfigure the PKT_CFG0 and PKT_LEN registers when the RX is active without having to strobe it to IDLE?
(ii) let us say I initially program the packet length register to be 255 and once I get the correct length from above description, I re-program the register with 50. Will the PKT_SYNC_RXTX be de-asserted after 255 or 50 bytes?
(iii) If it is de-asserted after 50 bytes, am I right in assuming that the first 50 bytes in the RxFIFO are the ones I am looking for?
(iv) is there a better way to do this at all?
Thanks,
Arun
(i) yes, this approach is used when people want to receive packets bigger that 128 also. The create an ISR that empties the FIFO and changes radio settings in realtime.
(ii) This will work, it will stop at 50 bytes.
(iii) you will have emptied some bytes already to decode your length word. So start with 50 and subtract the number of bytes you have already extracted from the FIFO and that will be the correct number. Say you set the statemachine to interrupt you when there is 7 bytes in the RX FIFO. You then proceed to get 5 of them, decode the length word you mentioned and reprogram the PKT_LEN register accordingly. If you program in 50, you have already taken 5, so you will only have 45 left at the very end.
(iv) This would be the approach we would recommend.
PS: I have built a demo of a pair of CC1120 transmitting a packet of 2000 bytes back and forth. This uses the above approach of reprogramming the PKT_LEN in realtime.
Regards,/TA
---------------------------------------------------------------------------------------------------------Please click the Verify Answer button on this post if it answers your question.---------------------------------------------------------------------------------------------------------
Just a comment to iii)
The PKT_LEN register should be set to the number of bytes the radio should receive after sync found and it does not matter when you set it as long as it is set before you reach that number. If your packet is 50 bytes after sync, PKT_LEN should be reprogrammed to 50, no matter if you have already read 5 or any number of bytes from the RX FIFO. For the example above, that means that if you have already read 5 bytes from your FIFO, the application has 45 bytes left to read, but PKT_LEN should be 50 as the radio should receive in total 50 bytes after sync.
BR
Siri
Thanks for both the suggestions! I was able to get my setup to work.
Regards
-Arun