Exact match. Not showing close matches.
'[PIC] Strange issue with writing to SFR (18F45K22)'
I have a new board, that updated the processor from an 16F877 to a 18F45K22, porting the code over.
However I ran across something that I haven't been able to really identify whats going on here.
This is a standard piece of code I use all the time with the 18F parts, and up to now I haven't seen any problems.
I'm using a ICD3 but not the latest version of MPLAB...its new enough to know what this part is of course, and builds
Without any issues. However I found that when I write to the EEPROM, data isn't getting in there so I put up a watch
Window and single stepped thru the code.
First off, the EEADR and EEDATA are not getting written to.
Next, the sequence of clearing and setting bits in the EECON1 register ..this works. The WREN bit gets set.
Then the magic sequence...doesnt get written to the EECON2 register
IF I push the values into the registers thru the watch window, indeed I can get the values written to the
What I find interesting is setting an individual bit works, but moving a byte in..doesnt.
This routine works...Ive used it on several 18F parts, and verified in the data sheet..ie...the example code, Is the same as well.
Any thoughts...why these SFR's are not being written to? Has to be something simple but after looking at it and Not seeing anything, just wonder if I am overlooking something ?
bcf EECON1, EEPGD
bcf EECON1, CFGS
bsf EECON1, WREN
bcf INTCON,GIE ;disable interrupt
bsf EECON1, WR
bsf INTCON,GIE ;re-enable interrupt - if interrupt is being used
btfsc EECON1,WR ;are we done? wait here till we are
Confidentiality Notice: This e-mail message, its contents and any attachments to it are confidential to the intended recipient, and may contain information that is privileged and/or exempt from disclosure under applicable law.. If you are not the intended recipient, please immediately notify the sender and destroy the original e-mail message and any attachments (and any copies that may have been made) from your system or otherwise. Any unauthorized use, copying, disclosure or distribution of this information is strictly prohibited. Email addresses that end with a ?-c? identify the sender as a Fusion-io contractor.
On Fri, May 4, 2012 at 11:51 AM, Harrison Cooper <fusionio.com> wrote: HCooper
> Then the magic sequence...doesnt get written to the EECON2 register
> IF I push the values into the registers thru the watch window, indeed I can get the values written to the
> Desired address.
> What I find interesting is setting an individual bit works, but moving a byte in..doesnt.
> This routine works...Ive used it on several 18F parts, and verified in the data sheet..ie...the example code,
> Is the same as well.
> Any thoughts...why these SFR's are not being written to? Has to be something simple but after looking at it and
> Not seeing anything, just wonder if I am overlooking something ?
I haven't used the EEPROM on that chip, so I haven't checked the
datasheet. But...I was once bit with a "K" part as some SFRs (USB ones
in this case) that used to be in access RAM suddenly weren't.
Modifying them through MPLAB worked fine, but I couldn't write
directly to them. Any chance you've got a banking issue?
-- A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
More... (looser matching)
- Last day of these posts
- In 2012
, 2013 only
- New search...