interrupt void monstermash_isr(void){ EALLOW; unsigned int value; unsigned long temp; value = ADC_get(); if(SRAMaddress <= 0x29FFFF & a == 0){ *SRAMaddress = value; SRAMaddress++; } else if(SRAMaddress <= 0x29FFFF && a ==1){ temp = *SRAMaddress; temp = temp+value; temp = temp/2; value = temp; //TODO:this is where attenuation would go *SRAMaddress = value; SRAMaddress++; if(SRAMaddress > 0x29FFFF){ b = 1; } } else if(b == 1){ DINT; SRAMaddress = 0x260000; changeFunctions(samplingRate); EINT; ERTM; } else{ SRAMaddress = 0x260000; a = 1; string_push("press 4 when second sample is ready"); int test = keypadScan(); while(test != 4){ test = keypadScan(); } LCDclear(); //changeFunctions(); //EINT; // Enable Global interrupt INTM //ERTM; // Enable Global realtime interrupt DBGM } }
int main(void){ DisableDog(); EALLOW; int test = 0; int laggingValue = 0xFF; unsigned int value = 0; EALLOW; CPUinit(); EALLOW; DINT; outputEnable(); initADC(); EALLOW; outputEnable(); //having issues when not enabling twice SRAMwrite(0); SRAMaddress = 0x260000; //DAC_init(); DAC_init(); timerINIT(); EALLOW; int oldvalue = 0; while(1){ // SRAMaddress = 0x2FFFFF; // *SRAMaddress = 0x77; if(a == 1){ //cross your fingers folks value = keypadScan(); *outputPORT = value; if(value < 0xF && value != 1 && oldvalue != value){ FreqSet(value); //setting the frequency based upon keypad input oldvalue = value; } } } EALLOW; return 0; }
void menu1() { incrementTime = 1; //Update display /* Change alarm */ while(changeAlarmState == 1) { int tempKeyPress = 0; delay(100); /* Update display to reflect chanegs made by user */ /* Debouce keypress and get keypress value */ while ( (tempKeyPress = keypadScan()) == 0 ) { delay(10); } keyPressValue = keypadScan(); while((tempKeyPress = keypadScan()) != 0) { delay(10); } /* Logic... */ if(keyPressValue == 1) { //Process option //Update display }else if(keyPressValue == 2) { //Process option //Update display }else if(keyPressValue == 5) { //Process option //Update display }else if(keyPressValue == 6) { //Process option //Update display }else if(keyPressValue == 9) { //Process option //Update display }else if(keyPressValue == 10) { //Process option //Update display }else if(keyPressValue == 16) { changeAlarmState = -1; }else { //Update display } } //Update display }