I am trying Generate a clock through PORT-A, but unfortunately it's not working at all. I tested the same code with PORTs B,C,D,E & F and it's working normally. Am I missing something in the initialization of PORT-A ? I disabled the alternative function and the analog mode too on PORT-A, but nothing is working!!
Here is the initialization code for all the PORTS:
void GPIO_INIT(){
SYSCTL ->RCGCGPIO |=0xFF; // Enable clock for all the ports
GPIOF -> LOCK = 0X4C4F434B; //Unlock PORTF
GPIOF -> CR = 0XFF; //Enable modifying PORTF registers
GPIOF -> DIR = 0XFF; //PORTF as output
GPIOF -> PUR = 0X00; //Disable Pull Up resistor
GPIOF -> DEN = 0XFF; //Enable digital function at PORTF
GPIOD -> LOCK = 0X4C4F434B;
GPIOD -> CR |= 0XFF;
GPIOD -> DIR = 0XFF;
GPIOD -> PUR = 0X00;
GPIOD -> DEN = 0XFF;
GPIOC -> LOCK = 0X4C4F434B;
GPIOC -> DIR = 0XFF;
GPIOC -> PUR = 0X00;
GPIOC -> DEN = 0XFF;
GPIOE -> LOCK = 0X4C4F434B;
GPIOE -> DIR = 0XFF;
GPIOE -> PUR = 0X00;
GPIOE -> DEN = 0XFF;
GPIOB -> LOCK = 0X4C4F434B;
GPIOB -> DIR = 0XFF;
GPIOB -> PUR = 0X00;
GPIOB -> DEN = 0XFF;
GPIOA -> LOCK = 0X4C4F434B;
GPIOA -> CR |= 0XFF;
GPIOA -> DIR = 0XFF;
GPIOA -> PUR = 0X00;
GPIOA -> DEN = 0XFF;
GPIOA -> AFSEL &= ~ 0XFF; //Disable Alternative functions on PORTA
GPIOA -> AMSEL &= ~ 0XFF; //Disable Analog mode on PORTA
}
int main()
{
GPIO_INIT();
while (1){
while((TIMER1->RIS & 0x00000001) != 1){} //Wait for Timer1 to time out
GPIOA ->DATA ^= (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7); //Toggle PORTA
TIMER1->ICR |= (1<<0); //Reset Timer1 flag
}
}
I Tested the code using a logic analyzer and it worked for all the Ports except PORT-A as I mentioned.