PreviousNext
IO Setup
Help > IO Setup

IO Setup feature is available at the [N]. It can be used to set up direction, pull-ups, and values of individual IO pins of the MCU at the very beginning of the device startup. Only DPA peripheral IO requests can be executed to make sure the device will always enter DPA Service Mode which can be used to fix an incorrect behavior. Also, every request must use HWPID equal 0xFFFF (HWPID_DoNotCheck). IO Setup DPA Requests are stored at external EEPROM memory starting from its physical address IOSETUP_EEEPROM_ADDR = 0x0040; 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 the IO Setup 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.

 

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.