I have a simple program to test pointer variable for 8051 and PIC. This variable uses to pass an IO port into a function. Here it is:
Code: Select all
void Port_LED_0(unsigned char *);
void Port_LED_1(unsigned char *);
void Port_LED_0(unsigned char *port)
{
(*port) = 0;
}
void Port_LED_1(unsigned char *port)
{
(*port) = 0xFF;
}
void main(void)
{
Port_LED_0(&P2); //For PIC: Port_LED_0(&PORTB);
Delay_ms(500);
Port_LED_1(&P2); //For PIC: Port_LED_1(&PORTB);
Delay_ms(500);
}
Thank you for reading.
Best regards.