0
\$\begingroup\$

I am trying to translate a couple of lines of code from AVR space data to STM8 normal C data manipulation.

As you should know, AVR has a program space which can storage data for read only operation, hence a special function should be used to read the data (pgm_read_byte()). In the case of STM8, it has a unique flash for program space and ram space, and storage data in program space is simple as using static constant keyword before the variable definition. The main problem for me is translate the AVR code to normal c code in STM8.

This is the line that I want to translate:

AMP[divider] = pgm_read_byte(envs[divider] + (((unsigned char*)&(EPCW[divider]+=EFTW[divider]))[1]))

And this is my translation:

EPCW[divider] += EFTW[divider];
AMP[divider] = EPCW[1+envs[divider]];

I am not sure if "EPCW[divider] += EFTW[divider];" is executed after or before of data reading in "pgm_read_byte()" function. And also I am not sure if the translated index are correct.

Thanks in advances.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.