View previous topic :: View next topic |
Author |
Message |
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
weird problem with pic16f886 |
Posted: Fri Jan 18, 2008 4:12 pm |
|
|
Hi people,
I was working on pic16f886 and i a weird problem happened.
the weak pullups on PORT_B just didnt work with PIN_B0 and PIN_B1.
I configured the pins as digital I/O and set the pullups with the following code:
Code: |
set_tris_b (0x07); // b0, b1 and b2 as inputs
*0x189=0; //ANSELH = 0; -> digital I/Os
port_b_pullups (TRUE); // WPUB = 0 - weak pullups on
|
to fixed the problem I needed to put external pullups on those pins (B1 and B2), B0 worked fine.
anybody has a clue to what happened ?
regards. _________________ Andre |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 18, 2008 4:48 pm |
|
|
Post your compiler version. |
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Fri Jan 18, 2008 9:17 pm |
|
|
IDE 4.032
PCB 4.032
PCM 4.032
PCH 4.032 _________________ Andre |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 18, 2008 10:59 pm |
|
|
The CCS start-up code has a lot of problems in your version. However,
that's not the main cause of your problem.
In your version, the Port B pullups can be individually enabled or disabled
for every pin in Port B. So you shouldn't use TRUE or FALSE with the
port_b_pullups() function. You should use a bitmask. Set a bit = 1
to enable a pullup, and set a bit = 0 to disable it. This is explained in
the 16F886 and the CCS manual. Because 'TRUE' is defined as 0x01,
when you do this you are really only enabling the pullup on pin B0:
Code: | port_b_pullups (TRUE); |
|
|
|
andreluizeng
Joined: 04 Apr 2006 Posts: 117 Location: Brasil
|
|
Posted: Sat Jan 19, 2008 9:08 am |
|
|
PCM, i got your point... but before I use port_b_pullups function, I directly set the register WPUB with 0xFF value, and it didnt work too. Probably I made something wrong.
however, I will try your sugestion.
thanks
regards. _________________ Andre |
|
|
|