IN PUT 5282 no 0 detecting

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IN PUT 5282 no 0 detecting

2,382件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

927件の閲覧回数
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 件の賞賛
返信

927件の閲覧回数
Lucho
Contributor I
Ok, May be I will practice with other Ports because I try with simples program with the PORTCP
0 件の賞賛
返信

927件の閲覧回数
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 件の賞賛
返信