3 User Flash Application Code
This chapter describes the user Flash example concept for the transmitter and the required project and fuse considerations that enable the transmitter to periodically send the intended message.
This section explains the function of the transmitter example code and indicates where to place it within the ATA8510 - XC8 based Software Project Template. For more details, refer to the ATA8510/ATA8210/ATA8710 - XC8 based Software Project Template.
This code configures the required pattern and loads it into the Data First-In, First-Out (DFIFO) buffer. It requests TXMode on service 0, channel 0, and path A.
txData represent the preamble and the start
frame ID {0xFF 0xFF 0xFF 0xFE}. The remaining four bytes (payload) are
used to verify successful reception {0x12 0x34 0x56 0x78}. Within the
firmware, the infinite loop handles the start of the TXMode and transmission. After
transmission, the system switches to IDLE mode and the AVR® core
enters the Sleep state. After approximately 2.1s, the watchdog triggers a system reset.
With a valid wake source present, the cycle starts from the beginning.- Enable the required API
functions in
wrap.candfw_defines.mk. - Ensure that the Boot Reset (BOOTRST) fuse is set to run the code stored in the user Flash memory.
uint8_t txData[8]={0xFF,0xFF,0xFF,0xFE,0x12,0x34,0x56,0x78}; API_SetSystemMode_C(BM_SYS_MODE_CONFIG_VCO_TUNING | OPM_TX, BM_SVC_CH_CONFIG_PATHA); API_WriteTxBuffer_C(txData,8); for( ;; ) { WDR; GPIORO ^= BIT MASK 2; /* toggle GPIOR0.2 to indicate main loop frequency */
ATA8510_FLASH_XC8.c). The remaining
code is for context only and indicates where the user needs to insert the range test
code.Fuse/Lock Bit Configuration Example
ATA8510_FLASH_XC8.c
file:#include <avr/io.h> FUSES = { .byte = 0xD3, // LOW {EXTCLKEN=CLEAR, RSTDISBL=CLEAR, BOOTRST=SET, EESAVE=SET, WDTON=CLEAR, SPIEN=SET, DWEN=CLEAR, CKDIV8=CLEAR} }; LOCKBITS = 0xFF; // {LB=NO_LOCK, AP=NO_LOCK_ON_SPM_AND_LPM_IN_APPLICATION_SECTION, BLP=NO_LOCK_ON_SPM_AND_LPM_IN_BOOT_LOADER_SECTION}
