PIC 18F anomaly!

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
20,926
Migrating to the 18Fx3K22 from the 18f2221 I thought would be easy, after 2 days frustration I found out why I could not set the I/O ports, I eventually did a web search and Voilà found it, may help someone else.
Using
clrf ANSELA
clrf ANSELB
clrf ANSELC
clrf CM1CON0
Did not work in the usual way, after replacing this with the movff instr. it works.
clrf WREG
movff WREG, ANSELA
movff WREG, ANSELB
movff WREG, ANSELC
movff WREG, CM1CON0
Found in the manual. (it helps to read it!)

Note 1: Addresses F38h through F5Fh are
also used by SFRs, but are not
part of the Access RAM. Users
must always use the complete
address or load the proper BSR
value to access these registers.
Max.
 

joeyd999

Joined Jun 6, 2011
4,410
This bit me before a few years ago. It pays to read the datasheet each time you use a new part. In this case, they had "too many" special function registers to fit in access RAM. At a minimum, I peruse the SFR table and the port pin description table. This keeps me out of trouble, generally.
 
Top