Site icon Renzo Mischianti

E220-900T22D: Can’t set higher UART baud rate

ResponseStatusContainer E220LoRaTransmitter::init() { transmitter.begin(); auto configurationStatus = this->getConfiguration(); auto configuration = *(Configuration*)configurationStatus.data; configuration.ADDL = 0x03; configuration.ADDH = 0x00; configuration.CHAN = 23; configuration.SPED.uartBaudRate = UART_BPS_9600; configuration.SPED.airDataRate = AIR_DATA_RATE_111_625; configuration.SPED.uartParity = MODE_00_8N1; configuration.OPTION.subPacketSetting = SPS_200_00; configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED; configuration.OPTION.transmissionPower = POWER_22; configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED; configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION; configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED; configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; configurationStatus.close(); return this->configure(configuration); } ResponseStatusContainer E220LoRaTransmitter::configure(Configuration configuration) { this->transmitter.setMode(MODE_3_CONFIGURATION); auto response= transmitter.setConfiguration(configuration,WRITE_CFG_PWR_DWN_SAVE); this->transmitter.setMode(MODE_0_NORMAL); return ResponseStatusContainer(response.code,response.getResponseDescription()); } This is the way I configure my LoRa module. However, whenever I try to set configuration.SPED.uartBaudRate = UART_BPS_XXXXXXX; My microcontroller (Arduino Nano esp32) goes in kernel panic at the moment of setting the configuration. I don't know if I am doing something else wrong, I am using HardwareSerial on digital pins 2 and 3, and connected the module in Normal Mode. M0, M1 are on D5 and D6, and I use the following constructor: E220LoRaTransmitter(HardwareSerial&serial,byteauxPin,bytem0Pin,bytem1Pin):transmitter(&serial,auxPin,m0Pin,m1Pin,UART_BPS_RATE_XXXXXX){}; (When XXXXXX = 9600 the module is correctly configured and works properly, with any other value I get the behaviour described before). The only "weird" thing I noticed is this method in your library: RESPONSE_STATUS LoRa_E220::checkUARTConfiguration(MODE_TYPE mode){ I don't understand why the check on the bps rate should fail with any other value, but changing that 9600 to any other value causes the module to refuse configuration: if(mode==MODE_3_PROGRAM&&this->bpsRate!=UART_BPS_RATE_9600){ returnERR_E220_WRONG_UART_CONFIG; } return E220_SUCCESS; } ResponseStatus LoRa_E220::setConfiguration(Configuration configuration, PROGRAM_COMMAND saveType){ ResponseStatusrc; rc.code =checkUARTConfiguration(MODE_3_PROGRAM); if(rc.code!=E220_SUCCESS)returnrc; MODE_TYPEprevMode=this->mode; rc.code =this->setMode(MODE_3_PROGRAM); if(rc.code!=E220_SUCCESS)returnrc; // this->writeProgramCommand(saveType, REG_ADDRESS_CFG); // configuration.HEAD = saveType; configuration.COMMAND =saveType; configuration.STARTING_ADDRESS =REG_ADDRESS_CFG; configuration.LENGHT =PL_CONFIGURATION; rc.code =this->sendStruct((uint8_t*)&configuration,sizeof(Configuration)); if(rc.code!=E220_SUCCESS){ this->setMode(prevMode); return rc; } rc.code =this->receiveStruct((uint8_t*)&configuration,sizeof(Configuration)); #ifdefLoRa_E220_DEBUG this->printParameters((Configuration *)&configuration); #endif rc.code =this->setMode(prevMode); if(rc.code!=E220_SUCCESS)returnrc; if(WRONG_FORMAT==((Configuration*)&configuration)->COMMAND){ rc.code =ERR_E220_WRONG_FORMAT; } if(RETURNED_COMMAND!=((Configuration*)&configuration)->COMMAND ||REG_ADDRESS_CFG!=((Configuration*)&configuration)->STARTING_ADDRESS ||PL_CONFIGURATION!=((Configuration*)&configuration)->LENGHT){ rc.code =ERR_E220_HEAD_NOT_RECOGNIZED; } return rc;
}
Exit mobile version