We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am building a Cypress USB-MCU AN2131QC board. I faced a problem of setting logic 1 from pins to Port A. Would anybody please tell us why is the code goes wrong? ^.^
#include "ezusb.h" #include "ezregs.h" void main() { PORTACFG = 0x00; // bits 7..0 are I/O OEA = 0x00; // port A for inputs // wait until pin 1 of Port A is set to logic 1 while(1) { // check input for pin 1 if( PINSA & bmBIT1 != 0 ) break; } // set port B PORTBCFG = 0xFF; OEB = 0xFF; OUTB = 0xFF; // my code always come to here no matter i set pin 1 of PORT A or not. // Is this right for input a logic for a pin??? }
"if( PINSA & bmBIT1 != 0 )" The "!=0" is superfluous anyway - The 'C' programming language will execute the controlled statement iff the value of the expression is nonzero. So you should just write
if( PINSA & bmBIT1 )