added frequency display
This commit is contained in:
parent
ad661c5c03
commit
1a1d72be7e
4 changed files with 60 additions and 1 deletions
43
frequency.c
Normal file
43
frequency.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driverlib/sysctl.h"
|
||||
#include "driverlib/gpio.h"
|
||||
#include "driverlib/timer.h"
|
||||
#include "driverlib/pin_map.h"
|
||||
#include "inc/tm4c1294ncpdt.h"
|
||||
#include "driverlib/interrupt.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
|
||||
#include "frequency.h"
|
||||
|
||||
|
||||
void start_frequency_scan() {
|
||||
// config GPIO PD0 as timer input T0CCP0 at BoosterPack Connector #1 pin 14
|
||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
|
||||
GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_0);
|
||||
GPIOPinConfigure(GPIO_PD0_T0CCP0);
|
||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
|
||||
TimerDisable(TIMER0_BASE, TIMER_BOTH);
|
||||
TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP);
|
||||
TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
|
||||
// use maximum load value
|
||||
TimerLoadSet(TIMER0_BASE, TIMER_A, 0xffff);
|
||||
// use maximum prescale value
|
||||
TimerPrescaleSet(TIMER0_BASE, TIMER_A, 0xff);
|
||||
TimerIntEnable(TIMER0_BASE, TIMER_CAPA_EVENT);
|
||||
TimerEnable(TIMER0_BASE, TIMER_A);
|
||||
}
|
||||
|
||||
uint32_t previous;
|
||||
void capture_handler() {
|
||||
TimerIntClear(TIMER0_BASE, TIMER_CAPA_EVENT);
|
||||
|
||||
uint32_t current = TimerValueGet(TIMER0_BASE, TIMER_A);
|
||||
|
||||
uint32_t delta = current - previous;
|
||||
gPeriod = delta;
|
||||
|
||||
previous = current;
|
||||
}
|
6
frequency.h
Normal file
6
frequency.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef FREQUENCY_C
|
||||
#define FREQUENCY_C
|
||||
void start_frequency_scan(void);
|
||||
|
||||
uint32_t gPeriod;
|
||||
#endif
|
6
main.c
6
main.c
|
@ -31,6 +31,7 @@
|
|||
#include "driverlib/pin_map.h"
|
||||
#include "sampling.h"
|
||||
#include "buttons.h"
|
||||
#include "frequency.h"
|
||||
#include "kiss_fft.h"
|
||||
#include "_kiss_fft_guts.h"
|
||||
|
||||
|
@ -149,6 +150,7 @@ int main(void)
|
|||
start_sampler();
|
||||
ButtonInit();
|
||||
start_cputimer();
|
||||
start_frequency_scan();
|
||||
|
||||
Crystalfontz128x128_Init(); // Initialize the LCD display driver
|
||||
Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); // set screen orientation
|
||||
|
@ -318,6 +320,10 @@ void display_waveform(UArg arg1, UArg arg2)
|
|||
GrContextForegroundSet(&sContext, ClrWheat);
|
||||
|
||||
snprintf(str, sizeof(str), "CPU Load %.1f%%", usage_percent);
|
||||
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 20, /*opaque*/ false);
|
||||
|
||||
float frequency = (float) gSystemClock / (float) gPeriod;
|
||||
snprintf(str, sizeof(str), "f = %.1fhz", frequency);
|
||||
GrStringDraw(&sContext, str, /*length*/ -1, /*x*/ 0, /*y*/ HEIGHT - 10, /*opaque*/ false);
|
||||
|
||||
|
||||
|
|
6
rtos.cfg
6
rtos.cfg
|
@ -535,7 +535,7 @@ var driversConfig = xdc.useModule('ti.drivers.Config');
|
|||
* Use TI-RTOS drivers library for debugging with asserts and logs enabled.
|
||||
*/
|
||||
driversConfig.libType = driversConfig.LibType_NonInstrumented;
|
||||
Clock.timerId = 0;
|
||||
Clock.timerId = 2;
|
||||
TimestampProvider.useClockTimer = true;
|
||||
var m3Hwi0Params = new m3Hwi.Params();
|
||||
m3Hwi0Params.instance.name = "m3Hwi0";
|
||||
|
@ -597,3 +597,7 @@ Program.global.options_sem = Semaphore.create(1, semaphore4Params);
|
|||
var gateHwi0Params = new GateHwi.Params();
|
||||
gateHwi0Params.instance.name = "gateHwiDMA";
|
||||
Program.global.gateHwi0 = GateHwi.create(gateHwi0Params);
|
||||
var m3Hwi1Params = new m3Hwi.Params();
|
||||
m3Hwi1Params.instance.name = "m3Hwi1";
|
||||
m3Hwi1Params.priority = 4;
|
||||
Program.global.m3Hwi1 = m3Hwi.create(35, "&capture_handler", m3Hwi1Params);
|
||||
|
|
Loading…
Reference in a new issue