PIT timers not working

Status
Not open for further replies.

jokm08

New member
Hi,

I have been trying to activate Timer 0 of the PIT timers. My intention is to get the LED to blink every 1 second. I have programmed it, but my code doesn't work. Below is my code:

//GPIO Registers
#define GPIO_C_PDOR (int*)0x400FF080
#define GPIO_C_PCOR (int*)0x400FF088
#define GPIO_C_PDDR (int*)0x400FF094
#define PORT_C_PCR5 (int*)0x4004B014

//Timer 0 Registers
#define Timer_PIT_MCR (int*)0x40037000
#define Timer_PIT_LDVAL0 (int*)0x40037100
#define Timer_PIT_CVAL0 (int*)0x40037104
#define Timer_PIT_TCTRL0 (int*)0x40037108

void setup() {
// put your setup code here, to run once:
volatile int * output_dir_c = GPIO_C_PDDR;
volatile int * clear_port_c5 = GPIO_C_PCOR;
volatile int * set_GPIO_c5 = PORT_C_PCR5;
volatile int * set_PIT_MCR = Timer_PIT_MCR;
volatile int * set_PIT_LDVAL0 = Timer_PIT_LDVAL0;

Serial.begin(9600);
while(!Serial);

Serial.print("Begin");
*output_dir_c = 0x00000020; //Set bit 5 of Port C as output bit
*clear_port_c5 = 0x00000020;
*set_GPIO_c5 = 0x00000100;
*set_PIT_MCR = 0x00000000;
Serial.print(*set_PIT_MCR,HEX);
Serial.print(*set_GPIO_c5,HEX);

Serial.print("GPIO setup okay");


Serial.print("Module control register okay");
*set_PIT_LDVAL0 = 0x00F42400;
Serial.print(*set_PIT_LDVAL0,HEX);
Serial.print("Setup okay");
}

The code compiles. But when I run it, the code gets stuck at the line "*set_PIT_MCR = 0x00000000". The code doesn't execute beyond this line. Could somebody help me out with this?.

Thank You,

Jose
 
Status
Not open for further replies.
Back
Top