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 CCS Technical Support

How to write to Data Memory in a PIC18F4620 ?

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



Joined: 09 May 2005
Posts: 35
Location: Toulouse (France)

View user's profile Send private message MSN Messenger

How to write to Data Memory in a PIC18F4620 ?
PostPosted: Fri Jan 11, 2008 8:08 am     Reply with quote

Hi...

I'm trying to adapt old programs, formerly coded for a PIC16F877 target, to run them now on a PIC18F4620. I compile my code using PCW C Compiler v3.249.

My problem is with Microchip's bootloader : I got ASM code from the Application Note AN851, and managed to have it to work on my microcontroller. To enter the boot mode, one need to write the value (0xFF) to the last address of Data Memory on the component, and to reset the PIC. The assembly code given by Microchip is the folowing :
Code:
setf EEADR
setf EEADRH
setf EEDATA
movlw b'00000100
movwf EECON1
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1, WR
nop
btfsc EECON1, WR
br a $-2  ; The actual line is "br a" withouth the space, but it's replaced by bra if I type it on the forum
reset

If I enter that into my C code, between #asm and #endasm tags, the compiler shows an error on the "bra $-2" line, because it seems the C compiler doesn't accept the "$" character. So I'm looking for the equivalent to those commands in C, if available, or any other way to write to the last address of the Data Memory. I tried to use "write_eeprom()", but it didn't seem to work (or maybe I don't use the right address ?).

Well, I begin to feel desperate about that bootloader issue : if anyone could help me, it'd be a great news. Wink

Regards,
Christophe.
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jan 11, 2008 8:38 am     Reply with quote

It would be easier to do this in C:

Code:
write_eeprom(LAST_LOC, 0xFF);
reset();


Function names are from memory, please check that they are right in CCS documentation!
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