bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
unsigned char pattern[8] = {0x3C,0x42,0xA5,0xA5,0x81,0xA5,0x5A,0x3C,};
address=0x0000;
while (address<0x0008)
{
for(counter=0;counter<8;counter++)
{
AT25_WriteByte(address,pattern[counter]);
_nop_();
_nop_();
address=address+0x0001;
}
}
Hello!
You should verify with the docs, but depending on the eeprom, you write the address once
and then you can write a sequence of bytes without re-entering the address each time.
And it stops at a page boundary or something like this. Well, red the docs!
Dora.
for(counter=0;counter<8
{
AT25_WriteByte(0000,pattern[counter]);
_nop_();
_nop_();
}
random data placement is only due to wrong address. since you have written a part of your full code so i can't say what exactly is going on. but the probable mistakes may be that ......
1) the manipulation of function
AT25_WriteByte(address,pattern[counter]);
may be out of Scope of variable "address", because the control of program destroy the memory space reserved for the variable when it jumps out of its scope.
2) in rest of your code you may be manipulating the address passed by the function wrongly; resulting in placement of remaining data wrong memory locations.
Guys,
How can I write a pattern into serial memory properly ?
Can I use a loop below ? with while ?
Or
Any other suggestions or experiences ?
Thanks
Code:unsigned char pattern[8] = {0x3C,0x42,0xA5,0xA5,0x81,0xA5,0x5A,0x3C,}; address=0x0000; while (address<0x0008) { for(counter=0;counter<8;counter++) { AT25_WriteByte(address,pattern[counter]); _nop_(); _nop_(); address=address+0x0001; } }
random data placement is only due to wrong address. since you have written a part of your full code so i can't say what exactly is going on. but the probable mistakes may be that ......
1) the manipulation of function
AT25_WriteByte(address,pattern[counter]);
may be out of Scope of variable "address", because the control of program destroy the memory space reserved for the variable when it jumps out of its scope.
2) in rest of your code you may be manipulating the address passed by the function wrongly; resulting in placement of remaining data wrong memory locations.
the code appers to be right....but i think you need to declear the unsigned char before address =0x0000; or declear it global ....also you need probably more dealy in the loop for correct data writting....
Good Luck
So you mean to say you are getting a compilation error.....which compiler r u using ?
Where can I find SDCC ? is it IDE ?this strange and superising....I uses generally SDCC complier I never face this problem........then what you can do is creat an array of addresses like unsigned char[] ={ 0x0000,0x0001....} and try to write but this will end up eating a space in micro-controller memory.....
Good Luck
uint address,counter;
unsigned char pattern[8] = {0x3C,0x42,0xA5,0xA5,0x81,0xA5,0x5A,0x3C,};
address=0x0000;
counter=0;
while (address<0x0008)
{
while (counter<8)
{
AT25_WriteByte(address,pattern[counter]);
}
} //end of while for address
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?