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

16F690 pullup bug ?

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



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

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

16F690 pullup bug ?
PostPosted: Fri Aug 17, 2007 8:47 am     Reply with quote

Ok, i'm pretty sure this isn't me.

The following 2 lines of code on the 16F690 compiled with ver 4.049:

Code:
   
port_a_pullups(0b00000011);
port_b_pullups(0);



Gives the following assembly code:

Code:

                01515 ....................    port_a_pullups(0b00000011);
*
0334 3003       01516 MOVLW  03
0335 1683       01517 BSF    STATUS.RP0
0336 0095       01518 MOVWF  WPUA
0337 1381       01519 BCF    OPTION_REG.RABPU
                01520 ....................    port_b_pullups(0);
0338 1283       01521 BCF    STATUS.RP0
0339 1703       01522 BSF    STATUS.RP1
033A 0195       01523 CLRF   WPUB
033B 1683       01524 BSF    STATUS.RP0
033C 1303       01525 BCF    STATUS.RP1
033D 1781       01526 BSF    OPTION_REG.RABPU



Which in my understanding means that at addresss 0337 it clears the RABPU bit in the option register to correctly turn on the pullups on port a and port b (one bit for both ports on this pic) but then at address 033D it sets the bit again turning them off.
Presumably because i'm not using any of the port B pullups, but they've missed the fact that it turns off the port A pullups as well which i am using 2 of.

Am i reading this code correctly and it is a compiler bug ?

If i swap the 2 lines so port_b_pullups is done first then the code works.

Thanks,

Jim
Ttelmah
Guest







PostPosted: Fri Aug 17, 2007 10:05 am     Reply with quote

The problem is that the compiler decides that because you are selecting '0', you want the pullups all off, and therefore kills the enable bit. If you set any port_b pullup on, it'll work. The code is not smart enough to realise that the enable is shared with the other port (since this is pretty much unique to this chip...).
It is a fault, but one that is easily avoided.

Best Wishes
Jim Hearne



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

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

PostPosted: Fri Aug 17, 2007 10:11 am     Reply with quote

Thanks for confirming that.
I've worked around it but it is a bug so i've sent it off to CCS
There is a whole series of chips with this port config so i guess the bug applys to them all.
PIC16F631, 677 ,685, 687, 689 & 690

Thanks,

Jim
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