Agam 0 Posted August 18, 2016 Share Posted August 18, 2016 I have modified the code and now the zero crossing interrupt is occurring.But the timer is still not functioning.Can anyone see and tell whether I have configured it right?#include "inc/hw_ints.h"#include "inc/hw_memmap.h"#include "inc/hw_timer.h"#include "inc/hw_types.h"#include "debug.h"#include "interrupt.h"#include "timer.h"#include "driverlib/prcm.h"#include "inc/hw_gprcm.h"#include "wiring_private.h"#include "driverlib/rom_map.h"#include "driverlib/pin.h"void setup(){pinMode(2,INPUT_PULLUP);pinMode(4,OUTPUT);noInterrupts();MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0,PRCM_RUN_MODE_CLK);MAP_PRCMPeripheralReset(PRCM_TIMERA0);MAP_TimerConfigure(TIMERA0_BASE,TIMER_CFG_B_PERIODIC_UP);MAP_TimerIntRegister(TIMERA0_BASE,TIMER_B,start);MAP_TimerIntEnable(TIMERA0_BASE,TIMER_TIMB_MATCH);MAP_TimerPrescaleSet(TIMERA0_BASE,TIMER_B,32);MAP_TimerMatchSet(TIMERA0_BASE,TIMER_B,7500);MAP_TimerLoadSet(TIMERA0_BASE,TIMER_B,0); MAP_TimerEnable(TIMERA0_BASE,TIMER_B );attachInterrupt(2,zeroCrossingInterrupt, RISING);interrupts();Serial.begin(9600);}void loop(){}void zeroCrossingInterrupt(){ digitalWrite(4,LOW);MAP_TimerLoadSet(TIMERA0_BASE,TIMER_B,0);MAP_TimerEnable(TIMERA0_BASE,TIMER_B );Serial.println("0k");}void start(){ digitalWrite(4,HIGH);MAP_TimerIntClear(TIMERA0_BASE,TIMER_TIMB_MATCH);MAP_TimerIntDisable(TIMERA0_BASE,TIMER_TIMB_MATCH);MAP_TimerDisable(TIMERA0_BASE,TIMER_B );Serial.println("hi");} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.