Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20563

Share your working BASCOM-AVR code here : RF22 library for Arduino : NEWTOPIC

$
0
0
Based on the original work from Mike McCauley at [url]http://www.airspayce.com/mikem/arduino/RF22/[/url] I have attached a Bascom conversion version of his "[b:098a8ee481]RF22 library for Arduino[/b:098a8ee481]" using the Hope-RF RF22B modules. No doubt this guy is experienced and knows his stuff it was no point re-inventing the wheel, so I decided to convert his Library. I am not (and never will be) a "C" user or a expert, I tried to convert his code as close as possible to original with some minor changes. All code conversion in based on [b:098a8ee481]V1.24[/b:098a8ee481] of Mike McCauley's code. All code has been tested using Sparkfun's RFM22 Shield with very minimal time testing see [url]https://www.sparkfun.com/products/11018[/url]. [i:098a8ee481]Changes compared to original code:[/i:098a8ee481] 1) No Timers used, I decided to free some resources by using a While/Wend statements in a loop using a calculated Counter value based on Crystal speed. This routine is mainly used for a Timeout where if a response is not made in a certain time it will return an error. I have tested it with various Crystals so it seems fairly accurate. The only negative issue is you cannot edit or change any code inside the Function as the FudgeFactor variable would need to be changed. 2) Initially I could not transmit or receive more than 127 bytes for some reason so I changed the way it the routine handles the Interrupts from the RF22 which now suits the various packet sizes. Theoretically it should handle any packet size (depending on your Ram) but I have only tested it with a 300 byte packet (to change buffer size change [b:098a8ee481]RF22_MAX_RX_MESSAGE_LEN[/b:098a8ee481] and [b:098a8ee481]RF22_MAX_TX_MESSAGE_LEN[/b:098a8ee481] found in RF22.inc). 3) Some routines where possible to convert from C to Bascom so I wrote similar working routines as replacement. Some original code would not work properly for some reason so some fixes had to be made as well. 4) rf22_mesh_xxxx.pde and rf22_router_xxxx.pde files were not converted as it was getting difficult converting some C code plus it requires to have 4 x RF22B modules to work, I figured for most it would not be useful. The only minor issue I have sometimes you have to press the reset button a couple of times to start/boot the code to work. I have scoped the SPI and compared it an original compiled Arduino version (and are the same), but the origianl always starts/boots straigh away.

Viewing all articles
Browse latest Browse all 20563

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>