IN PUT 5282 no 0 detecting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IN PUT 5282 no 0 detecting

2,381 Views
Lucho
Contributor I
Hi, my problems is that I can't detect a 0 in the register for IN PUT data, I only detec 1's This is my simple code:
 
int main()
{
    int i;
    MCF5282_GPIO_PBCDPAR = 0x00;
    MCF5282_GPIO_DDRB = 0xFF;
    MCF5282_GPIO_DDRC = 0x00;
    MCF5282_GPIO_PORTB = 0x00;  
    MCF5282_GPIO_PORTCP = MCF5282_GPIO_PORTCP & 0x01;
    while(1)
    {
         i = MCF5282_GPIO_PORTCP;
         if(i = 0x00){  
         MCF5282_GPIO_PORTB = 0x55;
         }
       if(i = 0x01){  
       MCF5282_GPIO_PORTB = 0xAA;
       }
    }// Idle
 return 0;
}
 
 This program is very simple but I can't do that the register MCF5282_GPIO_PORTCP detect a cero, it only detect logic 1's
Labels (1)
0 Kudos
Reply
3 Replies

926 Views
mccPaul
Contributor I
Hi
 
PortC is input so this:
 
MCF5282_GPIO_PORTCP = MCF5282_GPIO_PORTCP & 0x01;
 
is not doing anything.
 
You code only tests for PortC set to 0x00 or to 0x01 - maybe there is some other input to PortC, try and replace:
 
if(i = 0x01)
 
 with
 
else
 
Now you can see if there is any input detected at all.
 
Sorry I can't try out your code on one of my boards because I always have an external address bus and these ports are not available. If you find that you still have no result, can you try a different pair of ports?
 
Paul.
0 Kudos
Reply

926 Views
Lucho
Contributor I
Ok, May be I will practice with other Ports because I try with simples program with the PORTCP
0 Kudos
Reply

926 Views
stzari
Contributor III
Hi,

testing for a value might also make more sense than assigning one. :smileywink:
Your code should read:
Code:
if (i == 0x00) {
HTH
 Stamatis
 

0 Kudos
Reply