hello there,
i have just started to work with the TIVA C series launchpad. The part no. is TM4C123GXL board and the processor is TM4CGH6PM.
i wish to count the no. of rising edges from a stream of square waves and increment a counter to show the no. of square waves.
i am using timer0 ccp0 pin (PB6).
Please help.
here is my code:
#include<stdint.h>
#include<stdbool.h>
#include"inc/tm4c123gh6pm.h"
#include"inc/hw_types.h"
#include"inc/hw_memmap.h"
#include"driverlib/interrupt.h"
#include"driverlib/gpio.h"
#include"driverlib/timer.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include"driverlib/sysctl.h"
uint32_t count;
int main(void)
{
//uint32_t period;
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1);
GPIOPinConfigure(GPIO_PB6_T0CCP0);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE,TIMER_CFG_A_CAP_COUNT);
//period=SysCtlClockGet();
//period=(SysCtlClockGet()/20)/2;
//TimerLoadSet(TIMER0_BASE,TIMER_A,period-1);
IntEnable(INT_TIMER0A);
//TimerIntEnable(TIMER0_BASE,TIMER_CAPA_EVENT);
TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
TimerLoadSet(TIMER0_BASE, TIMER_A, 5);
TimerMatchSet(TIMER4_BASE, TIMER_A, 0);
IntMasterEnable();
TimerIntEnable(TIMER0_BASE, TIMER_CAPA_MATCH);
TimerEnable(TIMER0_BASE,TIMER_A);
while(1)
{
}
}
void Timer0IntHandler(void)
{
TimerIntClear(TIMER0_BASE, TIMER_CAPA_MATCH);
count++;
}