Port a TD1208 firmware to TD1508

TD1208/TD1508

TD1508 is the FCC version of the TD1208, they are pin to pin compatible and based on the same SDK so converting an object working on a TD1208 sounds easy. Practically speaking there are some preparing steps because of some tiny bugs to solve.

Let see how to port a Telecom Design existing firmware for TD1208 to TD1508 (from ETSI to FCC).

 

 

Compile the library for EZR

You first have to rename a file :

Rename a file

 

The file startup_efm32lg.s have to be renamed to startup_efm32lg.S if you do it directly from the file system don’t forget to refresh the folder in the Project Explorer.

 

 

 

 

Then as the chip in TD1508 is an Energy Micro EZR, so you need to recompile the library for this target:

You have to do it for all the libraries :

Lib you need to recompile with EZR target

Once done your project is ready to be recompiled.

Adapt the build settings

In the project template I have the TD1508 have its variable set to TD1208 value, so you can check this and fix it here:

Ensure the module revision setting is correct

Adapt your software

I2C

I2C pins are different so you have to adapt your I2C init.

#if MODULE_REVISION == REVISION_TD1508
    #define    I2C_SCL_PORT    gpioPortE
    #define I2C_SCL_BIT        1
    #define I2C_SDA_PORT    gpioPortE
    #define I2C_SDA_BIT        0
#else
    #define    I2C_SCL_PORT    SCL_PORT
    #define I2C_SCL_BIT        SCL_BIT
    #define I2C_SDA_PORT    SDA_PORT
    #define I2C_SDA_BIT        SDA_BIT
#endif

void my_I2C_Init_(void) {

    CMU_ClockEnable(cmuClock_GPIO, true);
#if MODULE_REVISION == REVISION_TD1508
    CMU_ClockEnable(cmuClock_I2C1, true);
#else
    CMU_ClockEnable(cmuClock_I2C0, true);
#endif

    GPIO_PinModeSet(I2C_SCL_PORT, I2C_SCL_BIT,gpioModeWiredAnd,1);
    GPIO_PinModeSet(I2C_SDA_PORT, I2C_SDA_BIT,gpioModeWiredAnd,1);    

    I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;

#if MODULE_REVISION == REVISION_TD1508
    I2C1->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (2 << _I2C_ROUTE_LOCATION_SHIFT);
    I2C_Init(I2C1, &i2cInit);
    // NVIC_ClearPendingIRQ(I2C1_IRQn);  // uncomment if you are using IRQ
    // NVIC_EnableIRQ(I2C1_IRQn);
#else
    I2C0->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | _I2C_ROUTE_LOCATION_LOC0;
    I2C_Init(I2C0, &i2cInit);
    // NVIC_ClearPendingIRQ(I2C0_IRQn);  // uncomment if you are using IRQ
    // NVIC_EnableIRQ(I2C0_IRQn);
#endif
    
}

Do not forget to also update your I2C read/write procedure and replace the I2C0 bus to I2C1 bus like this :

#if MODULE_REVISION == REVISION_TD1508
#define IC2BUS    I2C1
#else
#define IC2BUS    I2C0
#endif

    ...
    i2cTransfert.buf[1].len = 2;
    _status = I2C_TransferInit(IC2BUS, &i2cTransfert);
    while ( _status == i2cTransferInProgress) {
       _status = I2C_Transfer(IC2BUS);
    }
    ...

Radio Power

With a transmission at 24dB the power needed will be 240mA, time is shorter but consumption really higher. You have to ensure your object power supply can support a such peak. If not you need to limit the transmission power.

Consumptions are :

Tx Power Vcc Power
15dB 135mA
20dB 180mA
22dB 200mA
23dB 230mA
24dB 240mA

To select the right transmission power you can use the following function

TD_SIGFOX_RfPower(...);

You add as parameter the power in dB you want to use. According to the User Manual, I assume you can only choose 15,20,22,23,24dB.

Configure sigfox

The version 6.3.4 of the SDK have some bug on Sigfox configuration for FCC, so you need to manually call some functions on init to configure Sigfox communications on FCC. Only need to be called once.

uint32_t sigfox_fcc_macro_channel_bitmask[3];
sigfox_fcc_macro_channel_bitmask[0] = CONFIG_SIGFOX_FCC_MACRO_CHANNEL_BITMASK_LSB;
sigfox_fcc_macro_channel_bitmask[1] = CONFIG_SIGFOX_FCC_MACRO_CHANNEL_BITMASK_MID;
sigfox_fcc_macro_channel_bitmask[2] = CONFIG_SIGFOX_FCC_MACRO_CHANNEL_BITMASK_MSB;
TD_SIGFOX_SetMacroChannelBitmask(sigfox_fcc_macro_channel_bitmask);
TD_SIGFOX_SetDefaultMacroChannel(CONFIG_SIGFOX_FCC_DEFAULT_MACRO_CHANNEL);

 

Program the chip

With a JLink programmer you can use the following command to initiate the right chip:

# JLinkExe -device EZR32LG230F128 -if swd -speed 1000

Actually the Windows loader is not able to program the chip but you can program over the serial port with product ID = 31

./cflash -d /dev/ttyUSBx -b 115200 -p 31 firmware.bin

Still missing

According to the forum the chip have to be rebooted every 2 frame to work with sigfox network in USA, looking forward to find a workaround.

For those who are not afraid (if you don’t understand, just not try to do it) … another way to do is to search for the address of the channel variable in the .map file

.bss.Channel 0x20001788 0x2 C:\TD\TD_RF_Module_SDK-v6.0.0\Github\TD_RF_Module_SDK\lib\libtdrf\GCC Release EZR\libtdrf.a(td_sigfox_downlink.o)

Part in red above.

Once you have it, before any emit you can reset this value to 0 and the message will be sent on the initial frequency everytime. Just hope the lib will be soon fixed because it really durty.

uint16_t * channel = (uint16_t *)0x2000187e;

void resetFreq(){   *channel = 0;
}
This entry was posted in Hardware and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *