WStevens_sa
Member level 2
- Joined
- Jan 5, 2011
- Messages
- 47
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- South Africa
- Activity points
- 1,695
Hi
Can somebody please explain the following to me. I found a small program which basically turns an LED on and off.
I know the code below sends an output to PORT A0 with a delay. I know that
0x00 is an address, but what part of the code below actually tells it to send output to PORTA0 and how do I calculate the address for the others for example PORTA 1,2,3,4,5 or PORTB 1,2,3,4,5 and so on or is there a list according to which MCU use use. I have looked through the datasheet but cannot find it.
Thanks
void main()
{
int x = 1;
PORTA = 0x00; /*set RA0-RA5 low */
TRISA = 0x00; /*set PORTA to output*/
while(1)
{
PORTA = !PORTA;
Delay_ms(500);
}
}
Can somebody please explain the following to me. I found a small program which basically turns an LED on and off.
I know the code below sends an output to PORT A0 with a delay. I know that
0x00 is an address, but what part of the code below actually tells it to send output to PORTA0 and how do I calculate the address for the others for example PORTA 1,2,3,4,5 or PORTB 1,2,3,4,5 and so on or is there a list according to which MCU use use. I have looked through the datasheet but cannot find it.
Thanks
void main()
{
int x = 1;
PORTA = 0x00; /*set RA0-RA5 low */
TRISA = 0x00; /*set PORTA to output*/
while(1)
{
PORTA = !PORTA;
Delay_ms(500);
}
}