PreviousNext
Autoexec
Help > Autoexec

 

If the Autoexec feature is enabled at TR Configuration, then a series of DPA Requests can be executed at the boot time (after Init event) of the device. Both sender and addressee addresses of the requests equal 0xFC (local address). DPA Requests are stored in the block at the external EEPROM starting from the physical address AUTOEXEC_EEEPROM_ADDR = 0x0000. The size of the block is 64 bytes. DPA Requests are stored next to each other and are structured according to DPA protocol. There is one exception - the total size of the DPA Request in bytes is stored in the place of a corresponding NADR (in this case, it is only 1 byte wide, not 2 bytes as normal NADR). 0x00 is stored after the very last DPA Request to indicate the end of Autoexec batch. When executing DPA Request a local interface DPA Notification is not performed although DPA via the interface is enabled. Other events at the user DPA routine are called as usual. It is not allowed to embed Batch within a series of individual DPA Requests.

 

Important: Updating Custom DPA Handler code using the OTA LoadCode command does not allow writing external EEPROM content. Therefore the update of the Autoexec is not possible. It is recommended to avoid Autoexec when OTA is used.

 

Autoexec example:

 

The following example shows the bytes stored in the Autoexec external EEPROM memory space that will run these 4 actions upon the module reset:

1.   Switch the green LED On (PNUM=0x07)

2.   Open UART at 9 600 baud rate (PNUM=0x0C)

3.   Write hexadecimal  bytes [01,02,03,04,05] to the UART (PNUM=0x0C)

4.   Write hexadecimal bytes [06,07,08,09,0a] to the RAM at address 0x0A (PNUM=0x05)

 

Actual bytes stored at serial EEPROM from address 0x0000:

 

   Len   PNUM  PCMD        HWPID   PData

1. 0x05, 0x07, 0x01(LED On),  0xFFFF

2. 0x06, 0x0C, 0x00(UART open), 0xFFFF, 0x03(9 600 Baud)

3. 0x0b, 0x0C, 0x02(UART write),       0xFFFF, 0xFF(no UART read), {0x01, 0x02, 0x03, 0x04,  0x05}(data)

4. 0x0b, 0x05, 0x01(RAM write), 0xFFFF, 0x0a(address), {0x06, 0x07, 0x08, 0x09, 0x0a}(data)

5. 0x00(end of Autoexec)

 

C code to upload the Autoexec example to the external EEPROM:

 

#define NO_CUSTOM_DPA_HANDLER

 

#include "IQRF.h"

#include "DPA.h"

#include "DPAcustomHandler.h"

 

#pragma cdata[ __EEESTART + AUTOEXEC_EEEPROM_ADDR ] = \

/* Len PNUM       PCMD                 HWPID       PData */ \

   5,  PNUM_LEDG, CMD_LED_SET_ON,      0xff, 0xff, \

   6,  PNUM_UART, CMD_UART_OPEN,       0xff, 0xff, DpaBaud_9600, \

   11, PNUM_UART, CMD_UART_WRITE_READ, 0xff, 0xff, 0xff, 1, 2, 3, 4, 5, \

   11, PNUM_RAM,  CMD_RAM_WRITE,       0xff, 0xff, 0x0a, 6, 7, 8, 9, 10, \

0

 

☼ See example code DpaAutoexec.c for more details.