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

pic18f883 behaves strange with its I/O pins

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



Joined: 17 Aug 2007
Posts: 19

View user's profile Send private message

pic18f883 behaves strange with its I/O pins
PostPosted: Tue Oct 09, 2007 9:01 am     Reply with quote

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







PostPosted: Tue Oct 09, 2007 9:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 11, 2007 6:08 am     Reply with quote

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







PostPosted: Thu Oct 11, 2007 7:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 11, 2007 11:06 am     Reply with quote

These threads are about RMW problems, mostly with LEDs.
If you read all these posts, I think you will be able to fix your problem.
http://www.ccsinfo.com/forum/viewtopic.php?t=18183
http://www.ccsinfo.com/forum/viewtopic.php?t=25436
http://www.ccsinfo.com/forum/viewtopic.php?t=23756
http://www.ccsinfo.com/forum/viewtopic.php?t=21825&start=20
Mogge



Joined: 13 Aug 2007
Posts: 14
Location: Sweden

View user's profile Send private message

PostPosted: Sun Oct 14, 2007 1:51 pm     Reply with quote

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







PostPosted: Sun Oct 14, 2007 2:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 15, 2007 3:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 15, 2007 1:28 pm     Reply with quote

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 ?
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