cancel
Showing results for 
Search instead for 
Did you mean: 

ST72321R PortA Misbehaving??

dave_festing
Associate II
Posted on July 18, 2005 at 09:17

ST72321R PortA Misbehaving??

5 REPLIES 5
dave_festing
Associate II
Posted on July 13, 2005 at 09:57

PortA0 is set up an interrupt port AND LEDs are attached to PortA2 and PortA3 (all at ei0 interrupt level).

Even though interrupts are disabled changing PortA2 or PortA3 functionality causes improper operation of the interrupt port, when it is subsequently re-enabled.

I use a ''Unified port changing routine'', where you clear OR, set the DDR and then set the OR. This allows one change safely between the 4 port states without generating interrupts.

If I just turn the LEDs on and off by ONLY writing to PADR2 or 3 things work OK.

Also, if I move the LEDs to PortB I can use the port change routine without affecting PA0 interrupt port behaviour.

I have checked to see if unexpected interrupts were being generated and there were none.

Can anyone explain what I am doing wrong??

Thanks,

DaveF

wolfgang2399
Associate II
Posted on July 13, 2005 at 10:53

Hi Dave,

please notice: with OR=1 and DDR=0 you configurate a pull-up input with interrupt at port A0, A1 and A2.

You cannot configurate a pull-up input without interrupt feature at these ports. See also table 11 at chapter 9.5.1 of the datasheet.

Hope it helps

WoRo

dave_festing
Associate II
Posted on July 14, 2005 at 00:16

WoRo,

Thanks for the hint.

I thought I was setting this port up as a ''floating interrupt port'' but now I realise that it was being set up as a ''pull-up interrupt''. However, in my circuit this doesn't make any difference.

The interrupt capability of the port is disabled while I am programming the LEDs and I am doing a EICR write to clear any possible interrupts.

It appears to me that the cause is that these 3 ports are on the same ei0 interrupt level, because moving the LEDs to PortB ''fixes'' the problem. Can't think of how to prove it though!

Cheers,

Davef

wolfgang2399
Associate II
Posted on July 14, 2005 at 09:21

Hi DaveF,

even though I don't know your application here is another note:

If you only want to get your port at high-impedance you can use the open drain configuration (DDR=1, OR=0) and set the output ''high'' (DR=1).

In my application (with an ST72334) I use the port as a wired AND and it works without any problem concerning the interrupt input. To read the port value I only change the output from

DDR/OR: 1/0 (open drain output) to 0/0 (floting input) and backwards

keeping DR=1.

Regards

WoRo

dave_festing
Associate II
Posted on July 18, 2005 at 09:17

WoRo,

***

To read the port value I only change the output from

DDR/OR: 1/0 (open drain output) to 0/0 (floting input) and backwards keeping DR=1.

***

That is a safe transition for you, so all you need to do is change DDR.

If you were changing from output push-pull to input pull-up interrupt you need to do the following:

clear OR to get to output push-pull

write to DDR to get to input floating

write to OR to get to input pull-up interrupt.

If you are unsure of what state the port is actually in then doing the above guarantees safe transitions from any port state to any other port state. Well, that is the theory!

The above procedure ''appears'' to corrupt the input pull-up interrupt I have on PortA0, when I turn LEDs on and off on PortA1 and PortA2 . . . when I don't really need to change the port state.

I believe we are doing this as there might be a remote possibility that the port registers might get corrupted and this procedure should guarantee that the port is actually in the state you want.

If I do a DR write only, everything is OK. Perhaps the answer is . . . ''just do a DR write''!! I'll live with that for now.

Thanks again,

DaveF