AnsweredAssumed Answered

Strange Parallel Port behavior

Question asked by Jorge dAvila on Mar 19, 2014
Latest reply on Mar 19, 2014 by Edward Karpicz

Hi, guys,

 

I'm stuck with a strange Port Behavior. The code is so simple, I can't figure out what could be wrong. Please enlighten me! I'm using a MC9S08AC32 controller, programming in C - Codewarrion 10.5.

 

Take a look at this smple code:

 

PTCD_PTCD0 = 0;     // Initializing 2 port pins:

PTCD_PTCD1 = 0;     // Pin PTC0 to Output, 0

PTCDD_PTCDD0 = 1;   // Pin PTC1 to Input, 0 latched (but not output)

PTCDD_PTCDD1 = 0;


PTCDD_PTCDD1 = 1;   // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)

PTCDD_PTCDD1 = 0;   // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)

PTCDD_PTCDD1 = 1;   // Same Action, Same Result (AS EXPECTED)

PTCDD_PTCDD1 = 0;   // Same Action, Same Result (AS EXPECTED)

 

Now the surprising part. Look at this:

 

PTCD_PTCD0 = 0;     // Initializing 2 port pins:

PTCD_PTCD1 = 0;     // Pin PTC0 to Output, 0

PTCDD_PTCDD0 = 1;   // Pin PTC1 to Input, 0 latched (but not output)

PTCDD_PTCDD1 = 0;


PTCDD_PTCDD1 = 1;   // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)

PTCDD_PTCDD1 = 0;   // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)

PTCD_PTCD0 = 1;     // Setting the PTC0 Pin High (nothing to do with the PTC1, right?

PTCDD_PTCDD1 = 1;   // Ohooo... !!! Pin PTC1 does NOT go Low, as expected! It seems a "1" Value crept into the latch, the pin goes HIGH!

PTCDD_PTCDD1 = 0;

 

This happens either testing the code on chip, or in Full Chip Simulation.

I must confess I can't figure out what is happening here. I'm astonished to be stuck in so simple a piece of code.

Any ideas?

Outcomes