|
|
View previous topic :: View next topic |
Author |
Message |
Jim Hearne
Joined: 22 Dec 2003 Posts: 109 Location: West Sussex, UK
|
16F690 pullup bug ? |
Posted: Fri Aug 17, 2007 8:47 am |
|
|
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
|
|
Posted: Fri Aug 17, 2007 10:05 am |
|
|
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
|
|
Posted: Fri Aug 17, 2007 10:11 am |
|
|
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 |
|
|
|
|
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
|