View previous topic :: View next topic |
Author |
Message |
zilog
Joined: 17 Aug 2007 Posts: 19
|
pic18f883 behaves strange with its I/O pins |
Posted: Tue Oct 09, 2007 9:01 am |
|
|
Compiler: CCS V4.050, MCU: PIC16F883
The MCU drives 4 leds, which are lighted by pulling the corresponding I/O pin low. The leds are attached to A4, A5, A6 and A7. If I set A4 to output (high or low does not matter) - then the led attached to A5 becomes lighted, that is gets a low logic level.
We use a couple of I/Os as analog inputs for the internal AD-converter, we also use SPI in master mode, and timers 1 and 2. We dont use any comparators (for safety, we have tested explicitly disabling these).
What could be causing this behaviour? |
|
|
Ttelmah Guest
|
|
Posted: Tue Oct 09, 2007 9:39 am |
|
|
It sounds as if something is preventing A5, going properly high.
When you perform any pin output on the PIC, you perform a 'RMW' cycle. This reads the values on the pins, modifies the one you want to change, and writes the whole result back to the port (read, modify, write). This is why if their is any significant capacitance on a pin, you must wait for significant time between changing this pin, and updating any other pin.
It sounds as if A5, is reading as 'low' all the time. It doesn't have to actually be at 0v, but just below the voltage that the chip detects as a logic 0.
Best Wishes |
|
|
Mogge
Joined: 13 Aug 2007 Posts: 14 Location: Sweden
|
|
Posted: Thu Oct 11, 2007 6:08 am |
|
|
Good shot.
But no; when initiated that pin is an output only, and drives a indicator LED locally. There is no chance anything could back-drive that pin hard enough.
Weird; it worked when laste updated a month or so ago, but recompiling that program it no longer works...
Now we also tested the same code on a 28-pin prototyping board from Microchip, with PIC16F886 (only difference is more memory.)
Same behaivour. So probably not hardware.
The prototype is unreachable a couple of weeks, and we must work on other parts first, but we will investigate further later. |
|
|
Ttelmah Guest
|
|
Posted: Thu Oct 11, 2007 7:52 am |
|
|
The pin doesn't have to be 'back driven'. If (for instance), your 'LED', does not have a large enough current limiting resistor, then it could prevent the pin going 'high'.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Mogge
Joined: 13 Aug 2007 Posts: 14 Location: Sweden
|
|
Posted: Sun Oct 14, 2007 1:51 pm |
|
|
I still don't get why the exact same unmodified circuit board worked before but not after later changes in other part of code. (and with later compiler version)
But we will change to use port buffering as that is a good idea anyway that I usually use when doing it in assembly...
Thanks for the input. |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 14, 2007 2:32 pm |
|
|
It only takes a tiny fraction of a volt change in the Vf of the LED, for the effect to become apparent. I'd guess that you are just on the edge of the problem, and either the board layout changed the line resistance a tad, or possibly even just a change in temperature has bought the problem to light. Vf, reduces by about 2mV/C, so if the board is hotter than it was, and your were 'borderline', the problem can appear.
Best Wishes |
|
|
Mogge
Joined: 13 Aug 2007 Posts: 14 Location: Sweden
|
|
Posted: Mon Oct 15, 2007 3:09 am |
|
|
The change is observed on the exact same board idividual, and also replicated ona a separate board with another PIC, that have only two leds connected to the PIC, and that with 1k resistors in series.
So the only parts of interest is the PIC internal design, compiler, and source code.
I think that for some reason the the comparators (that we do not use) in the PIC at that pin is somehow not initialised correctly anymore, and thus cause a RMW issue. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 15, 2007 1:28 pm |
|
|
Quote: |
I think that for some reason the the comparators (that we do not use) in
the PIC at that pin is somehow not initialised correctly anymore, and thus
cause a RMW issue. |
Currently you are using vs. 4.050. What was the compiler version
that you used before this one ? |
|
|
|