PreviousNext
IO Setup
Help > IO Setup

IO Setup feature can be used to set up direction, pull-ups, and value of individual IO pins of the MCU at the very beginning of the device startup. It is very similar to Autoexec except only DPA peripheral IO requests are executed in order to make sure the device will always enter DPA Service Mode that can be used to fix an incorrect behavior. Also every request must use HWPID equal 0xFFFF (HWPID_DoNotCheck). IO Setup DPA Requests likewise Autoexec ones are stored at external EEPROM memory but, in this case, starting from its physical address IOSETUP_EEEPROM_ADDR = 0x0040; the size of the block is 64 bytes (it is located just after Autoexec memory space

 

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

 

IO Setup example:

 

The following example shows the bytes stored in the IO Setup external EEPROM memory space that will run these 2 commands upon the module reset:

1.     Sets PORTB.7 (controls green LED) as output

2.     Sets green LED on for 1s and then off for 1s

 

Actual bytes stored at serial EEPROM from address 0x0040:

 

   Len   PNUM  PCMD        HWPID        PData

1. 0x08, 0x09, 0x00(IO Direction),       0xFFFF,      {1,0x80,0x00}(B.7 = output),

2. 0x11, 0x09, 0x01(IO Set),   0xFFFF,      {1,0x80,0x80}(B.7 = 1), {0xff,0xe8,0x03}(1s delay), {1,0x80,0x00}(B.7 = 0), {0xff,0xe8,0x03}(1s delay),

3. 0x00(end of IO Setup)

 

C code to upload IO Setup example to the external EEPROM:

 

#define NO_CUSTOM_DPA_HANDLER

 

#include "IQRF.h"

#include "DPA.h"

#include "DPAcustomHandler.h"

 

#pragma cdata[ __EEESTART + IOSETUP_EEEPROM_ADDR ] = \

8,  PNUM_IO, CMD_IO_DIRECTION, 0xff, 0xff, \

PNUM_IO_TRISB, 0x80, 0x00, \

17, PNUM_IO, CMD_IO_SET, 0xff, 0xff, \

PNUM_IO_PORTB, 0x80, 0x80, \

PNUM_IO_DELAY, 0xe8, 0x03, \

PNUM_IO_PORTB, 0x80, 0x00, \

PNUM_IO_DELAY, 0xe8, 0x03, \

0

 

☼ See example code DpaIoSetup.c for more details.