void initDACPage(void) { DAC_init(); // sets mode triangle DAC_TriangleAmplitude(10); //log2(DAC_START_AMPLITUDE) sAmplitude = DAC_START_AMPLITUDE; DAC_Timer_initialize(0xFF); // Don't really need value here sLastFrequencySliderValue = DAC_START_FREQ_SLIDER_VALUE; }
/* Configures the board hardware and chip peripherals for the project's functionality. */ void configHardware(void){ USB_ConfigureClock(); PORTR.DIRSET = 1 << 1; PORTR.OUTSET = 1 << 1; _delay_ms(50); PORTR.OUTCLR = 1 << 1; DAC_init(); initADC(); initChannels(); USB_Init(); }
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; }
interrupt void test_isr(void){ if (a == 1){ EALLOW; DAC_init(); a = 0; } if(SRAMaddress <= 0x2FFFFF){ DAC_set(*SRAMaddress); SRAMaddress++; } CpuTimer1.InterruptCount++; EALLOW; }
int main() { serial_init(); AI_init(); DAC_init(); Timer10Sec(); //p.16 //stage1(); //p.18 //stage2(); //p.16 & p.18 //stage3(); //p.25 stage4(); return 0; }
int main(void) { DisableDog(); CPUinit(); EALLOW; outputEnable(); LCDinit(); LCDclear(); initADC(); DAC_init(); // SRAMwrite(0); // SRAMaddress = 0x260000; //shouldn't need SRAM here fft_init(); initBuffers(); timerINIT(ISRvalue, samplingRate); while(1){ if(sampleBufferFull){ fft.InBuf = &sampleBuffer[0]; int i; for(i = 0;i<FFT_SIZE;i++){ outBuffer[i] = 0; } for(i=0;i<FFT_SIZE/2;i++){ MagBuffer[i] = 0; } RFFT_f32(&fft); //fft.MagBuf = &sampleBuffer[0]; RFFT_f32_mag(&fft); sampleBufferFull = 0; EINT; } else{ //do nothing } } return 0; }
/*---------------------------------------------------------------------------- * main: initialize and start the system *----------------------------------------------------------------------------*/ int main (void) { uint32_t button_msk = (1U << Buttons_GetCount()) - 1; osKernelInitialize (); // initialize CMSIS-RTOS // initialize peripherals SystemCoreClockConfigure(); // configure System Clock SystemCoreClockUpdate(); LED_Initialize(); // LED Initialization Buttons_Initialize(); // Buttons Initialization // create threads tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL); osKernelStart (); // start thread execution DAC_init(); DAC_enable(); for(Counter=0;Counter<182;Counter++) { DAC_value2[Counter]=DAC_value1[Counter]/2; } Counter=0; for (;;) { if (Counter<=0)Direction=0; else if (Counter>179)Direction=1; if (Direction==0)Counter++; else Counter--; DAC_write(DAC_value2[Counter]); // DAC_write(4000); // osDelay(100); // while (Buttons_GetState() & (button_msk)); // Wait while holding USER button // DAC_write(0); // osSignalSet(tid_blinkLED, 0x0001); } }
int main(void) { DisableDog(); CPUinit(); EALLOW; outputEnable(); LCDinit(); LCDclear(); initADC(); DAC_init(); init_buffer(); timerINIT(ISRvalue, samplingRate); while(1){ } return 0; }
int main(void){ DisableDog(); EALLOW; unsigned int test = 0; int laggingValue = 0xFF; //unsigned int value = 0; EALLOW; CPUinit(); EALLOW; DINT; outputEnable(); initADC(); EALLOW; DAC_init(); EALLOW; outputEnable(); //having issues when not enabling twice EALLOW; timerINIT(); EALLOW; while(1){ } EALLOW; return 0; }
void motor_init(){ DAC_init(); //Set port K as input DDRK = 0x00; pinMode(OE, OUTPUT); pinMode(RST, OUTPUT); pinMode(SEL, OUTPUT); pinMode(EN, OUTPUT); pinMode(DIR, OUTPUT); //Enable motor digitalWrite(EN, HIGH); //Set !OE high to disable output of encoder digitalWrite(OE, HIGH); //Set !RST reset_encoder(); //Calibrate calibrate_encoder(); controll_motor(0); }
int main(void) { FRESULT res; WORD br; sei(); // Globally enable interrupts hibernate_init(); DAC_init(); keys_init(); if (pf_mount(&fs)) { sound_osch(); } else { sound_gut(); } while(1) { cli(); // disable interrupts to avoid race condition with sleep function if (FLAG_CHECK(NEW_SOUND)) { hibernate_timer_stop(); FLAG_CLEAR(NEW_SOUND); sei(); switch (special_mode) { case 1: if (new_sound_id == old_sound_id - 1) { special_mode = 2; goto sound_ende; } else if (new_sound_id == old_sound_id + 1) { special_mode = 4; goto sound_ende; } else if (new_sound_id == old_sound_id) { credits_counter = CREDITS_COUNTER_MAX - 5; special_mode = 0; goto sound_ende; } else special_mode = 0; break; case 2: special_mode = 3; break; case 4: special_mode = 5; break; default: special_mode = 0; } if (new_sound_id == 36) { special_mode = 1; goto sound_ende; } old_sound_id = new_sound_id; char* filename; if (++credits_counter > CREDITS_COUNTER_MAX) { credits_counter = 0; filename = "image.hex"; } else { if (new_sound_id == 255) goto sound_ende; filename = filenames(bank, new_sound_id); } uint8_t tries = 3; while (pf_open(filename) && pf_open("error1.wav")) { if ((tries--) == 0) goto sound_ende; _delay_ms(10); pf_mount(&fs); } if (parse_wav_header()) { if (pf_open("error2.wav") || parse_wav_header()) goto sound_ende; } do { #define read_length 16384 if (wavinfo.data_length > read_length) { res = pf_read(0, read_length, &br); wavinfo.data_length -= read_length; } else { res = pf_read(0, wavinfo.data_length, &br); break; } } while (res==0 && br==read_length && wavinfo.data_length>0 && !FLAG_CHECK(NEW_SOUND)); stop_audio(); sound_ende: hibernate_timer_init(); } else { sleep_enable(); sei(); sleep_cpu(); sleep_disable(); } hibernate_check(); } }