sandropiovesana
Joined: 06 May 2008 Posts: 9
|
Problem with WRITE_EEPROM and READ_EEPROM on PIC12F519 |
Posted: Wed Jun 25, 2008 9:09 am |
|
|
This is correct code:
#include <12F519.h>
#FUSES NOMCLR, NOPROTECT, NOWDT, INTRC, NOPROTECTDF, IOSC8
#USE DELAY(CLOCK=4000000)
#USE FAST_IO(B)
unsigned int data = 0;
void main(void)
{
Set_Tris_B(0b11110000);
Output_Low(PIN_B0);
Output_Low(PIN_B1);
write_eeprom(0x1, 0x5);
data = read_eeprom(0x1);
#ASM
BCF 0x4,0x5
#ENDASM
if (data == 0x5) Output_High(PIN_B0);
else Output_High(PIN_B1);
while (TRUE)
{
}
}
This is NOT correct code:
#include <12F519.h>
#FUSES NOMCLR, NOPROTECT, NOWDT, INTRC, NOPROTECTDF, IOSC8
#USE DELAY(CLOCK=4000000)
#USE FAST_IO(B)
unsigned int data = 0;
void main(void)
{
Set_Tris_B(0b11110000);
Output_Low(PIN_B0);
Output_Low(PIN_B1);
write_eeprom(0x1, 0x5);
data = read_eeprom(0x1);
// #ASM
// BCF 0x4,0x5
// #ENDASM
if (data == 0x5) Output_High(PIN_B0);
else Output_High(PIN_B1);
while (TRUE)
{
}
}
There is a bug on CCS Compiler:
the function write_eeprom() or read_eeprom() set bank1 with
BSF 0x4,0x5
when start, but not reset
BCF 0x4,0x5
when they finish, so if i use output_high() function, it dosn't work because the trisB is in bank0 not in bank1.
Good Luck. |
|