Hello i am pretty new to modbus and this is my first program with it, I have several registers (21) 16bit register and some of them are NVM (non volatile memory) capable.
So, in order to save 16 bit register value to eeprom I am splitting the data into 8 bits such as
[INPUT_SAMPLE] //(basically this is a 16 bit register that samples out the adc between 200-2000 range) default val is 200
If(DUL==YES){
Stm8_eeprom_store_data (u_8 analog[input_samples >>8) ;
Stm8_eeprom_store_data (u_8 analog[input_samples) ;}
Stm_wdt // calling watchdog
I tried this code but it didn’t help instead
if (DUL==YES){
Stm8_eeprom_store_data (((u_8)analog[input_samples>>8)+((u_8)analog[input_samples);
}
This code helped but the thing is, I can’t store values greater than 255(8bit) my question is that do I need to convert it back to 16bit.
NOTE: I am using stm8l52c6 IC with modbus , the nvm is properly configured everything is working the only thing that’s frustrating me is that I can’t store val greater than 247-255 (8bit) . To read the configured registers I am using modbus tester & scada admin
I’d appreciate any quick and meaningful response from your end. Thank you in advance.
I was expecting it to store 16bit value but since my eeprom can only read 8 bit values that’s why I had to split the 16 bit into 8bit but the thing is now it can store only 8 bit data if I try entering 16bit value for eg 2000; it would output some random value as 208 …why is that so? Do I need to convert the 8 bit to 16 bit again or what