Tool/software: Code Composer Studio
Hi for every one
I'm trying to use timer0 as input edge counter, i did all the steps mentioned in the data sheet but I've no response at all .
this my code
#include "tm4c123gh6pm.h"
void systemClockInit()
{
SYSCTL_RCC_R = 0x0;
SYSCTL_RCC_R |= (1<<0);// Enable the main oscillator
SYSCTL_RCC_R &= ~(3<<4);// configure main oscillator as input
SYSCTL_RCC_R |= (0x15<<6);// 16M OSC.
SYSCTL_RCC_R &= ~(1<<11);// Enable PPL
SYSCTL_RCC_R |= (1<<20);// Disable PWM clock division
}
void enableBusAndClock()
{
SYSCTL_GPIOHBCTL_R = 0x3B;// Enable AHB for Ports {A,B,D,E,F}
SYSCTL_RCGCGPIO_R = 0x3B;// Enable clock for ports {A,B,D,E,F}
}
void alterantivePinSet()
{
GPIO_PORTB_AHB_AFSEL_R = 0xF3;// Alternative Pin set for B {0,1,4,5,6,7} Counter
GPIO_PORTB_AHB_DIR_R = 0xF3;
GPIO_PORTB_AHB_DEN_R = 0xF3;
GPIO_PORTD_AHB_AFSEL_R = 0x01;// Alternative Pin set for D {0} PWM
GPIO_PORTD_AHB_DEN_R = 0x01;// Enable Digital function
/
GPIO_PORTB_AHB_PCTL_R |= (7<<0)|(7<<4)|(7<<16)|(7<<20)|(7<<24)|(7<<28);// Enable counter function on Port B pins
GPIO_PORTD_AHB_PCTL_R |= (5<<0);// Enable PWM function on D {0}
}
void timersConfiguration()
{
SYSCTL_RCGCTIMER_R = 0x07;// Enable clock to Timers {0,1,2}
TIMER0_CTL_R &= ~(1<<0);// Disable the timer 0
TIMER0_CFG_R = 0x4;// Configuring the module 0 as counter
TIMER0_TBMR_R = (0x03)|(1<<4);// Configuring the module (0,B) as counter and as up counter
TIMER0_CTL_R &= ~(3<<10) & ~(3<<2);// Configuring module {A,B} positive edge
TIMER0_TBPMR_R = 0x0;// configuring APMR to 254
TIMER0_TBMATCHR_R = 0xFF;
TIMER0_TBPR_R = 0xFF;
TIMER0_TBILR_R = 0x0000FFFF;
TIMER0_CTL_R |= (1<<0);// Enable the timer 0
}
int main(void) {
systemClockInit();
enableBusAndClock();
alterantivePinSet();
timersConfiguration();
while(1)
{
}
}