Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Interrupt problem with LM3S8962

$
0
0

Hi all, i'm working with LM3S8962 evolution board in my project and i'm using IAR embeeded Working bench to develop my code.But i'm facing a big problem with interrupt, actually when i inject a signal and i i want to calculate its periode , it returns nothing .I want to know how i can detect the interrupt .

You can find my code below , please can you help me to correct it .

i'm working with Timer0A and i want to receive the interrupt on the pine PD4

#include "inc/hw_types.h"
#include "inc/hw_nvic.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "utils/uartstdio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "drivers/rit128x96x4.h"

unsigned long First; // Timer0A first edge
unsigned char Done; // set each rising
unsigned long Period; // 167 ns units

void InitConsole(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);
UARTprintf("Periode1 ->\n");
}

void InitPORT(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // activate port D
GPIOPinConfigure(GPIO_PD4_CCP0 ); // enable digital I/O on PD4 // enable alt funct on PD4
GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_4);
GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_4);
GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_RISING_EDGE);
// GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_4);
}
void InitTimer(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);// activate timer0
TimerConfigure(TIMER0_BASE,TIMER_CFG_16_BIT_PAIR|TIMER_CFG_A_CAP_TIME);//configure for 16-bit timer mode
TimerControlEvent(TIMER0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);//configure for rising edge event
TimerLoadSet(TIMER0_BASE,TIMER_A,0xFFFF);// start value
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE,TIMER_CAPA_MATCH );// enable capture match interrupt
TimerEnable(TIMER0_BASE,TIMER_A);//TimerA Enable G
IntPrioritySet(19,2);// Timer0A=priority 2
IntMasterEnable();
IntEnable(19);

}
void Timer0IntHandler()
{
// Clear the timer interrupt.
TimerIntClear(TIMER0_BASE,TIMER_CAPA_MATCH);

First = 0; // first will be wrong
Done = 0; // set on subsequent
TimerMatchGet(TIMER0_BASE,TIMER_A);// acknowledge timer0A capture match

Period = (First -TimerLoadGet(TIMER0_BASE,TIMER_A ))&0xFFFF;// 167ns resolution
First = TimerValueGet(TIMER0_BASE,TIMER_A); // setup for next
Done = 0xFF;
}
int main (){
InitConsole();
InitPORT(); 
UARTprintf("Periodefinale ->\n");
InitTimer();

//for(;;){

UARTprintf("'%d%d%d ", Period);
Timer0IntHandler();
//}}


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>