Hi,
How to make '20' Nanoseconds delay in Timer?
in Example Time code to convert for 20 Nanoseconds for our Testing. The Code given to Below.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
// System clock rate in Hz.
uint32_t g_ui32SysClock;
// Flags that contain the current value of the interrupt indicator as displayed on the UART.
uint32_t g_ui32Flags;
// Configure the UART and its pins. This must be called before UARTprintf().
void ConfigureUART(void)
{
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 115200, g_ui32SysClock);
}
// The interrupt handler for the first timer interrupt.
void Timer0IntHandler(void)
{
char cOne;
uint32_t Load_Value = 0U, Match_Value = 0U, TimerClock_Value = 0U;
MAP_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerClock_Value = MAP_TimerClockSourceGet(TIMER0_BASE);
Load_Value = MAP_TimerLoadGet(TIMER0_BASE, TIMER_A);
Match_Value = MAP_TimerMatchGet(TIMER0_BASE, TIMER_A);
HWREGBITW(&g_ui32Flags, 0) ^= 1;
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, g_ui32Flags);
MAP_IntMasterDisable();
cOne = HWREGBITW(&g_ui32Flags, 0) ? '1' : '0';
UARTprintf("\r***************************************************");
UARTprintf("\rT1: %c", cOne);
UARTprintf("\rSysClock: %d", g_ui32SysClock);
UARTprintf("\rTimerClock: %d", TimerClock_Value);
UARTprintf("\rLoadValue: %d", Load_Value);
UARTprintf("\rMatchValue: %d", Match_Value);
MAP_IntMasterEnable();
}
// The interrupt handler for the second timer interrupt.
void Timer1IntHandler(void)
{}
// This example application demonstrates the use of the timers to generate periodic interrupts.
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_240), 120000000);
ConfigureUART();
UARTprintf("\nTimers example\n");
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC_UP);
MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, (g_ui32SysClock / 60000000));
MAP_IntMasterEnable();
MAP_IntEnable(INT_TIMER0A);
MAP_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
MAP_TimerEnable(TIMER0_BASE, TIMER_A);
while(1)
{
}
}