I would like to make sure whether the following code works correctly or not.
-----
static void setOUT(unsigned char *pPOUT) {
*pPOUT |= BIT0;
}
void testFunc(void)
{
unsigned char *pPOUT = 0;
char cond;
cond = 1; // for test
switch(cond) {
case 1:
pPOUT = (unsigned char *)&P1OUT;
break;
case 2:
pPOUT = (unsigned char *)&P2OUT;
break;
}
if (pPOUT != 0) {
setOUT(pPOUT);
}
}
-----
By now, I have never tried to use pointer for PxOUT (*pPOUT). I have directly set the port such as
P2OUT |= BIT0;
P3OUT |= BIT5;
However, when I need to consider a code, which will be commonly used in different MSP430, I need to use the pointer.
So that's the reason why I would like to know the correct way.