Hello,
I’m trying to use the SX1272 LoRa Shield on a Nucleo -L433RC board with the LoRaWan example provided by mbed.
The shield is not pin-to-pin compatible (mainly the SPI interface) with the Nucleo board so I connected both boards using cables and modified the mbed_app.json file to redefine the pins I used to connect both boards and to set the SX2172 as lora-radio as follows:
"config": {
"lora-radio": {
"help": "Which radio to use (options: SX126X, SX1272, SX1276) -- See config/ dir for example configs",
"value": "SX1272"
},
"main_stack_size": { "value": 4096 },
"lora-spi-mosi": { "value": "PA_7" },
"lora-spi-miso": { "value": "PA_6" },
"lora-spi-sclk": { "value": "PA_5" },
"lora-cs": { "value": "PA_4" },
"lora-reset": { "value": "PA_0" },
"lora-dio0": { "value": "PA_12" },
"lora-dio1": { "value": "PB_3" },
"lora-dio2": { "value": "PB_5" },
"lora-dio3": { "value": "PA_15" },
"lora-dio4": { "value": "NC" },
"lora-dio5": { "value": "NC" },
"lora-rf-switch-ctl1": { "value": "NC" },
"lora-rf-switch-ctl2": { "value": "NC" },
"lora-txctl": { "value": "NC" },
"lora-rxctl": { "value": "NC" },
"lora-ant-switch": { "value": "NC" },
"lora-pwr-amp-ctl": { "value": "NC" },
"lora-tcxo": { "value": "NC" }
},
"target_overrides": {
"*": {
"platform.stdio-convert-newlines": true,
"platform.stdio-baud-rate": 115200,
"platform.default-serial-baud-rate": 115200,
"lora.over-the-air-activation": true,
"lora.duty-cycle-on": true,
"lora.phy": "US915",
"lora.device-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
"lora.application-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }",
"lora.application-key": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 }",
"target.components_add": ["SX1272"]
},
The code compiles but I’m getting a hardfault message:
++ MbedOS Fault Handler ++
FaultType: HardFault
Context:
R 0: 00000000
R 1: 20010000
R 2: 00000001
R 3: 20010000
R 4: 20010000
R 5: 00000003
R 6: 20001260
R 7: 20003AD8
R 8: 20003AE8
R 9: 20004540
R 10: 00000000
R 11: 00000000
R 12: 080015A5
SP : 20003A8C
LR : 0800ADEB
PC : 080101E4
xPSR : 01000200
PSP : 20003A68
MSP : 2000FFC0
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000082
BFSR : 00000000
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
MMFAR: 00000000
Mode : Thread
Priv : Privileged
Stack: PSP
-- MbedOS Fault Handler --
++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x80101E4
Error Value: 0x20003BC0
Current Thread: main Id: 0x20002338 Entry: 0x8002841 StackSize: 0x1000 StackMem: 0x20002BC0 SP: 0x20003A8C
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=NUCLEO_L433RC_P
-- MbedOS Error Info --
I had similar faults when some interface was assigned to a pin not designed for such interface, so I checked the mbed_config.h file after compiling to see if the pins were set correctly and found the new pins are there:
#define MBED_CONF_APP_LORA_CS PA_4 // set by application
#define MBED_CONF_APP_LORA_DIO0 PA_12 // set by application
#define MBED_CONF_APP_LORA_DIO1 PB_3 // set by application
#define MBED_CONF_APP_LORA_DIO2 PB_5 // set by application
#define MBED_CONF_APP_LORA_DIO3 PA_15 // set by application
#define MBED_CONF_APP_LORA_DIO4 NC // set by application
#define MBED_CONF_APP_LORA_DIO5 NC // set by application
#define MBED_CONF_APP_LORA_PWR_AMP_CTL NC // set by application
#define MBED_CONF_APP_LORA_RADIO SX1272 // set by application
#define MBED_CONF_APP_LORA_RESET PA_0 // set by application
#define MBED_CONF_APP_LORA_RF_SWITCH_CTL1 NC // set by application
#define MBED_CONF_APP_LORA_RF_SWITCH_CTL2 NC // set by application
#define MBED_CONF_APP_LORA_RXCTL NC // set by application
#define MBED_CONF_APP_LORA_SPI_MISO PA_6 // set by application
#define MBED_CONF_APP_LORA_SPI_MOSI PA_7 // set by application
#define MBED_CONF_APP_LORA_SPI_SCLK PA_5 // set by application
Also on the same file I found this #define lines:
#define MBED_CONF_SX1272_LORA_DRIVER_SPI_CS NC // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_SPI_FREQUENCY 8000000 // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_SPI_MISO NC // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_SPI_MOSI NC // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_SPI_SCLK NC // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_TCXO NC // set by library:sx1272-lora-driver
#define MBED_CONF_SX1272_LORA_DRIVER_TXCTL NC // set by library:sx1272-lora-driver
So I´m not sure the mbed_app.json is actually being used or not to set the SX1272 pins correctly.
Any ideas or suggestions are more than welcome!
Best regards,
Lalo