Topics Topics Edit Profile Profile Help/Instructions Help Member List Member List  
Search Last 1|3|7 Days Search Search Tree View Tree View  

PIC 16F88 - nasty little tripwire - A...

:: EPE Chat Zone ­:: ­Radio Bygones Message Board :: » EPE Forum Archives 2007-2009 » Archive through 25 February, 2008 » PIC 16F88 - nasty little tripwire - ADRESH, ADRESL « Previous Next »

  Thread Last Poster Posts Pages Last Post
  ClosedClosed: New threads not accepted on this page        

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

dave_g
Frequent Contributor
Username: dave_g

Post Number: 419
Registered: 05-2005

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, 24 February, 2008 - 06:49 pm:   Edit Post Delete Post Print Post    Move Post (Moderator/Admin Only)

Dear all - hope you don't mind me sharing a frustrating little nasty with a PIC.

I have a project using the A-D convertor and part way through, decided I wanted to use 9 bits, not 8. Originally, I just decided to use ADRESH (the high byte) which suited me just fine.

However, as the monster develops I then find I want just bit 7 of ADRESL (the low byte). No problem, I just bit test ADRESL,7 but no data. Code looks fine, compiles fine in MPLAB, etc.

Because by this time I have LCD displays hooked up with timing loops, etc, I didn't go the trouble of using the simulator, as after all, it's not that complex...

ADRESL is in Page 1 memory, ADRESH in Page 0. This had me going for hours...:-(

Remember to set RP0, RP1 appropriately just to read ADRESL. Seems a daft memory map to me!

Hope this saves someone some time.

Same is true of PIC16F87x, so I'm sure this has been covered before, but I had forgotten and made an ASSumption.
Top of pagePrevious messageNext messageBottom of page Link to this message

john_becker
:::: Super User ::::
Username: john_becker

Post Number: 1754
Registered: 05-2005

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, 24 February, 2008 - 07:24 pm:   Edit Post Delete Post Print Post    Move Post (Moderator/Admin Only)

Dave, if you look at the Microchip .INC file for a PIC it will tell you which bank (page) ADRESL & ADRESH are, if ADC exists on that PIC.

J
Top of pagePrevious messageNext messageBottom of page Link to this message

dave_g
Frequent Contributor
Username: dave_g

Post Number: 420
Registered: 05-2005

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, 24 February, 2008 - 10:27 pm:   Edit Post Delete Post Print Post    Move Post (Moderator/Admin Only)

However, addressing ADRESL via just it's mnemonic doesn't work, so it's a case of either checking or remembering to change page.

Incidentally I've just had a look at P16F88.INC and it's not clear, although it is simple to look at the datasheet.
Top of pagePrevious messageNext messageBottom of page Link to this message

terrym
Frequent Contributor
Username: terrym

Post Number: 567
Registered: 05-2005

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, 25 February, 2008 - 07:30 am:   Edit Post Delete Post Print Post    Move Post (Moderator/Admin Only)

Yes, page (or bank) addressing , has tripped me up a couple of times as well. Have got into the habit of putting variables that need to be accessible to the various banks in memory locations that can be accessed from any bank. 70h on from memory for the '88.

TM
Top of pagePrevious messageNext messageBottom of page Link to this message

atferrari
Frequent Contributor
Username: atferrari

Post Number: 535
Registered: 05-2005


Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, 25 February, 2008 - 08:35 am:   Edit Post Delete Post Print Post    Move Post (Moderator/Admin Only)

It took me time to get used to check if BANKSEL and BANKISEL were required before ANY access to variables in RAM.

SFRs (special function registers) are in fixed locations so the habit of grouping registers in the common bank is of no use. Keeping a map handy helps a lot.
Agustín Tomás - Buenos Aires - Argentina

Administration Administration Log Out Log Out   Previous Page Previous Page Next Page Next Page