cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM addressing issue

Chayan Roy
Associate III
Posted on April 15, 2017 at 14:44

Hello,

Here is my code for writing a byte into internal eeprom. Problem is  when -ever  I write a byte to the internal data rom ,its is  written to (address+1)  place into the  rom ...what I  mean to say..is ..if I try to  write some  value say..8 ..at a specific address ..say..0x4021,the value  is written to  the address 0x4022 instead of address 0x4021.  I am readingthe written content in STVP. Am I making  any mistake......any suggestion will be great help to me. Thanks.

#include 'STM8S003F3P.h'

 unsigned int *ptr=(unsigned int *)0X4000;

 

main()

{

while (1){

if(!(FLASH_IAPSR & (1<<3))){

                            

                            FLASH_DUKR=0XAE;

                            FLASH_DUKR=0X56;

                            

                            *ptr++=7;

                            FLASH_IAPSR &=~(1<<3);

                            

                            

                            

                            }

}

}
3 REPLIES 3
Posted on April 15, 2017 at 17:27

>>

unsigned int *ptr=(unsigned int *)0X4000;

Perhaps unsigned char would be more appropriate for a pointer that advances one byte at a time?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Chayan Roy
Associate III
Posted on April 15, 2017 at 18:41

Thanks Clive for your reply...I will  do this

Chayan Roy
Associate III
Posted on April 16, 2017 at 13:55

Hello Clive its working now. Thanks