To demonstrate how to pass back a value we can write the readEEPROM function,
You should be able to look at the datasheet now and see how it's the same as the example on page 98.
To test this we need to add a prototype and we'll use a global variable to store the result.
So, at the top of the code is,
test is our new variable and we can test the readEEPROM routine straight after the writeEEPROM,
Now, when we compile, run and then pause the code, we can hover over the variable and see it contains 0x23,
And we know that works too.
Mike.
You should be able to look at the datasheet now and see how it's the same as the example on page 98.
Code:
unsigned char readEEPROM(unsigned char address){
EEADRL=address;
CFGS=0;
EEPGD=0;
RD=1;
return(EEDATL);
}
To test this we need to add a prototype and we'll use a global variable to store the result.
So, at the top of the code is,
Code:
void sendDDSword(int);
void writeEEPROM(unsigned char,unsigned char);
unsigned char readEEPROM(unsigned char);
unsigned char test;
void main(void){
Code:
WPUA = 0x00;
writeEEPROM(0,0x23);
test=readEEPROM(0);
while(1){
And we know that works too.
Mike.
Last edited: