ADGAN
Full Member level 5
- Joined
- Oct 9, 2013
- Messages
- 295
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 18
- Activity points
- 1,837
Hi! This is the code I wrote for the internal EEPROM of PIC16F887 using MikroC pro. But when I simulate in Proteus it seems to be not working. What is wrong with the code?
Code:
#define Highest(param) ((char *)¶m)[3]
#define Higher(param) ((char *)¶m)[2]
#define Hi(param) ((char *)¶m)[1]
#define Lo(param) ((char *)¶m)[0]
unsigned short int t1,t2,t3,t4;
unsigned long pulses;
void main(){
pulses = (count*65536)+ (TMR1H<<8 | TMR1L);
EEPROM_Write(0x00, Highest(pulses));
Delay_ms(20);
EEPROM_Write(0x01, Higher(pulses));
Delay_ms(20);
EEPROM_Write(0x02, Hi(pulses));
Delay_ms(20);
EEPROM_Write(0x03, Lo(pulses));
Delay_ms(20);
t1 = EEPROM_Read(0x00);
Delay_ms(20);
t2 = EEPROM_Read(0x01);
Delay_ms(20);
t3 = EEPROM_Read(0x02);
Delay_ms(20);
t4 = EEPROM_Read(0x03);
Delay_ms(20);
pulses = ((t4 << 0) & 0xFF) + ((t3<< 8) & 0xFF00) + ((t2 << 8) & 0xFF0000) + ((t1 << 8) & 0xFF000000) ;
}
Last edited: