CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with WRITE_EEPROM and READ_EEPROM on PIC12F519

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sandropiovesana



Joined: 06 May 2008
Posts: 9

View user's profile Send private message

Problem with WRITE_EEPROM and READ_EEPROM on PIC12F519
PostPosted: Wed Jun 25, 2008 9:09 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group