Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 14:9cfe0041cc4e
- Parent:
- 13:27300c533dd1
- Child:
- 15:1c67f064278e
--- a/main.cpp Sat May 09 13:45:23 2020 +0000 +++ b/main.cpp Tue May 19 15:04:33 2020 +0000 @@ -8,15 +8,15 @@ Username: el18loc Student ID Number: 201225242 Start Date: 06/02/2020 -Last Edited: 04/05/2020 +Last Edited: 19/05/2020 */ /* TO DO: +Generate sound add Menu functionality from front.cpp front.h warning sort Settings tab -Generate sound -ADSR +ADSR (functionaluty) MIDI LEDS INSTALL */ @@ -37,52 +37,52 @@ N5110 lcd; Menu menu; startup start; -Ticker down; -Ticker period; +Ticker tick; -DigitalOut rca(PTC4); -Serial pc(USBTX, USBRX); +//DigitalOut rca(PTC4); +//Serial pc(USBTX, USBRX); //Functions //void squareWave(); //void sinspeak(); -//void down_isr(); -//void up_isr(); +void noise_isr(); //Global Variables -// all times drastically slowed to attempt debugging in teraterm -//float g_period = 0.002; -//float g_unused= g_period*1000000.0f; -//int g_period_us=g_unused; -//volatile uint64_t g_uptime_us = g_period_us/2; // placeholder value -//isr interrupt flags -//volatile int g_upflag=1; -//volatile int g_downflag=1; - - //volatile extern uint16_t sin_wavtable[1024]; - //volatile extern double sin_d[1024]; - - -volatile extern uint16_t sin_wavtable[1024]; -volatile extern uint16_t tri_wavtable[1024]; -volatile extern uint16_t pulse_wavtable[1024]; +volatile extern int g_isr_flag; //may need extern int main() { printf("RUNNING CODE \n"); start.initialise(lcd,pad); //initialises board and displays start screen + +#ifdef DEBUG + printf("DEBUG COMPILE RUNNING\n"); + run_LUTs_debug(); +#endif + +#ifdef SLOW_TIME //ATTACH TICKERS FOR SOUND + tick.attach_us(&noise_isr, 100000); //extended for debug (1Hz) +#else + tick.attach_us(&noise_isr, 250); //normal mode (4kHz) +#endif + + menu.mainmenu(lcd,pad); - #ifdef DEBUG - printf("DEBUG COMPILE RUNNING\n"); - run_LUTs_debug(); - #endif - - menu.mainmenu(lcd,pad); +//UNUSED FUNCTIONS:------------------------------------------------------------- //squareWave(); //generates pulse wave modulated by sin wave //sinspeak(); } +void noise_isr() { + #ifdef SLOW_TIME + if (g_isr_flag==0) { + printf("ISR INTTERUPT = 1\n"); + } + #endif + g_isr_flag=1; + } + /* void squareWave() { @@ -125,29 +125,6 @@ } } -void down_isr() //sets rca to 0 -{ - //printf("downISR \n"); - if (g_downflag==0) {//stops error trigger - rca.write(0); - g_downflag=1; - g_uptime_us= g_uptime_us+g_period_us; // eliminates it calling if =0 - //printf("0 \n");//print only in while v. slow freguency - } -} - -void up_isr() //sets rca=1 -{ - //printf("upISR \n"); - rca.write(1); - down.attach_us(&down_isr,g_uptime_us); //timer to set rca=0 after elapsed - g_upflag=0; //sets flag to iterate - g_downflag=0; //sets flag to allow set to 0 - //printf("1 \n"); //only in while at v low frequency -} - -*/ -/* void sinspeak () { float f1=440.0;