void a_main() { // Debug trigger enable_LED(PORTL0); disable_LED(PORTL0); // Initialize components uart_init(); uart1_init(); init_ADC(); mode_PORTA_INPUT(JOYSTICK_PIN_HORZ); mode_PORTA_INPUT(JOYSTICK_PIN_VERT); DDRA = 0xFF; disable_LED(PORTL0); disable_LED(PORTL2); disable_LED(PORTL5); disable_LED(PORTL6); // Initialize tasks Task_Create(Task_ReadJoystick, 1, 0); Task_Create(Task_WriteBluetooth, 2, 0); Task_Create(Idle, 10, 0); // Kill the initialization task Task_Terminate(); }
void Setup(void) { /*****************************************************************/ /* Ports en Entrée */ TRISD=0xFFFF; TRISB=0xFFFF; TRISC=0xFFFF; /*****************************************************************/ /* Ports en Sortie */ TRISF=0x0000; TRISE=0x00F0; /*****************************************************************/ /* Port c en digital */ ANSELC=0x0000; ANSELE=0x0000; /*****************************************************************/ /* TRISx pour le can */ TRISFbits.TRISF2 = 1; //Input for CAN TRISFbits.TRISF3 = 0; //Output for CAN /*****************************************************************/ /* Fonction d'initialisation du PIC */ initialisation_CLK(); init_ADC(); initialisation_UART(); /*****************************************************************/ }
int main() { pic_init(); logging_init(); button_init(); bumper_init(); pwm_init(); motor_timer_init(); button_timer_init(); sound_config_timer_init(); //put_str_ln("Initialising DMA..."); //init_DMA(); //put_str_ln("Initialising ADC..."); init_ADC(); // setup des interrupts INTCONSET = _INTCON_MVEC_MASK; __builtin_enable_interrupts(); if (VERBOSE_PIC_STATUS) put_str_ln("Ready."); while (1) { WDTCONbits.WDTCLR = 1; // ecrire un 1 dans ce bit force la reinitialisation du watchdog } }
int main(void) { InitIO(); init_ADC(); InitTimer1(); InitTimer2(); InitExtInt(); while(1) { switch(display_select) { case 0x00: MusicOnLed(); break; case 0x01: FadeOnLed(); break; case 0x02: StrobeOnLed(100, 100, 100); break; /* . . TODO:: Sync up pin change interrupts for the last push button . */ case 0xFF: ColorOnLed(1,0,1); break; } } }
int main(void) { // Local Variable // char a=0; // Initialize Function // init_PORT(); init_EX_INTERRUPT(); init_TIMER0(); init_TIMER3(); init_ADC(); //init_USART(); sei(); while(1) { } return 0; }
//main function void main(void) { unsigned int result; unsigned char a,b; init_ADC(); TRISD = 0; ADCON0bits.GO = 1;//Start conversion by setting the GO/~DONE bit while(1) { if(display_enable) { //get result from registers ADRESH & ADRESL result = ADRESH; result = result << 8; result = result | ADRESL; temperature = (result*10)/31; a = temperature%10; b = temperature/10; LATD = (a<<4)|b; display_enable = 0; ADCON0bits.GO = 1;//Start conversion by setting the GO/~DONE bit } } }
int main(void) { // initialize the GPIO pins we need initClock(); init_GPIO(); init_ADC(); init_DAC(); init_GYACC(); usb::init(); Herkulex hercules; GPIOE->ODR |= 0xC000; Tools::Delay(Tools::DELAY_AROUND_1S / 2); GPIOE->ODR &= ~0xC000; enable_ADC_watchdog(2760, 3870); // ~6.9V -- ~9.5V (V33 = 3.41V) hercules.setTorque(DEFAULT_ID, TORQUE_ON); unsigned debounce = 10000, oldb=0; unsigned g = GYACC_txrx(USE_GYRO, 0x8F00); unsigned a = GYACC_txrx(USE_ACC, 0xA000); for(;;) { char p[4]; uint32_t r = usb::read(p); for (int i=0; i < r; ++i) p[i] += 2; usb::write(p, r); if (r) GPIOE->ODR += 0x4000; if (!debounce--) { const unsigned b = ~GPIOC->IDR; const unsigned p = (b ^ oldb) & b; if (p & 2) { GPIOE->ODR ^= 0x8000; hercules.positionControl(DEFAULT_ID, 512 + 300, 40, 0); } else if (p & 4) { GPIOE->ODR ^= 0x4000; hercules.positionControl(DEFAULT_ID, 512, 40, 0); } else if (p & 8) { GPIOE->ODR -= 0x4000; hercules.positionControl(DEFAULT_ID, 512 - 300, 40, 0); } oldb = b; debounce = 10000; } } }
//main code int main(void) { //init stuff //init the ht1632c LED matrix driver chip ht1632c_init(); //init the ADC init_ADC(); //init srand() with a somewhat random number from ADC9's low bits init_srand(); //init button stuff for input and pullup //and setup INT0 for button if you set DO_YOU_WANT_BUTTON_INT0 init_button(); //init timer1 for use in triggering an interrupt //on overflow, which updates the display and calculates new generation. init_timer1(); //init the I/O for the 7 segment display control init_digit_pins(); init_segment_pins(); //reset the display with a "random" array using rand() reset_grid(); //test glider //fb[29] = 0b00100000; //fb[30] = 0b00101000; //fb[31] = 0b00110000; //variable to store generation_count for display on 7 segment displays uint16_t g_count=0; //enable global interrupts sei(); //infinite loop while(1){ //check if the update generation count flag has been set //by within the timer1 overflow interrupt. //if set put the updated value into g_count and reset the flag. if(update_gen_flag){ g_count = generation_count; update_gen_flag=0; } write_number(g_count); //write the g_count to 7 segment displays //write_number(generation_count); //if the seven_seg_error flag is set (output is over 999 for 3 digits) //then reset the grid if(seven_seg_error_flag){ reset_grid(); } } }
int main() { uint8_t refTemp = 30; // reference uint8_t check, prev_check = 0; short up = 1, down = 1; uint16_t adc_in; // ADC value uint8_t temp = 1; // real temperature init_controller(); init_PWM(); lcd_init(); sei(); // turn on interrupts lcd_clrscr(); lcd_puts("Spinning"); Delay_s(2); // 2 seconds delay init_ADC(); refTemp = eeprom_read_byte((uint8_t*)0); if (!(refTemp >= TMIN && refTemp <= TMAX)) refTemp = 30; while(1) { if (C_CHECKBIT(Minus_REF)) down = 0; if (C_CHECKBIT(Minus_REF) == 0 && down ==0) { down = 1; if (refTemp > TMIN) refTemp--; } if (C_CHECKBIT(Plus_REF)) up = 0; if (C_CHECKBIT(Plus_REF) == 0 && up ==0) { up = 1; if (refTemp < TMAX) refTemp++; } eeprom_write_byte ((uint8_t *)0, refTemp); adc_in = ReadADC(0); temp = adc_in/2; lcd_puts2("T%d-R%dC", temp, refTemp); if ((temp - refTemp) > TOL) check = 3; else if ((refTemp - temp) > TOL) check = 1; else check = 2; switch(check) { case 1: if (prev_check == 1) break; setDutyCycle1(); prev_check = 1; break; case 2: if (prev_check == 2) break; setDutyCycle2(); prev_check = 2; break; case 3: if (prev_check == 3) break; setDutyCycle3(); prev_check = 3; break; } } return 1; }
void ad_init() { RCC_PeriphClockCmd(RCC_ADC1, ENABLE); RCC_PeriphClockCmd(RCC_GPIOC, ENABLE); init_GPIO(GPIOC, GPIO_Pin_0, GPIO_Mode_AN, GPIO_Fast_Speed, GPIO_OType_PP, GPIO_PuPd_NOPULL); initCommon_ADC(ADC_Mode_Independent, ADC_Prescaler_Div2, ADC_DMAAccessMode_Disabled, ADC_TwoSamplingDelay_5Cycles); init_ADC(ADC_Resolution_12b, DISABLE, ENABLE, ADC_ExternalTrigConvEdge_None, ADC_ExternalTrigConv_T1_CC1, ADC_DataAlign_Right, 1); ADC_Cmd(ADC1,ENABLE); ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_144Cycles); }
void main(void) { WDTCTL = WDTPW + WDTHOLD; init_ADC(); init_OUT(); init_WDT(); // everything else happens in the watchdog timer }
/********************************************Programme Principal************************************************/ int main(void) { init_OSC(); init_dsPIC(); init_DAC(); init_ADC(); while(1) { val=convertADC()*64; } return 0; }
void Setup(void) { /* Initialisation de l'horloge Section 7.7 PLL (PHASE-LOCKED LOOP)*/ _PLLPRE=0; _PLLPOST=0; _PLLDIV=(unsigned int) (4.0f*FOSC_MHZ/(7.37f))-1; while(OSCCONbits.LOCK !=1); //boucle ok /*****************************************************************/ /* Ports en Entrée */ TRISD=0xFFFF; TRISB=0xFFFF; TRISC=0xFFFF; /*****************************************************************/ /* Ports en Sortie */ TRISF=0x0000; TRISE=0x00F0; /*****************************************************************/ /* Port c en digital */ ANSELC=0x0000; ANSELE=0x0000; /*****************************************************************/ /* TRISx */ TRISFbits.TRISF2 = 1; //Input for CAN TRISFbits.TRISF3 = 0; //Output for CAN /*****************************************************************/ init_ADC(); initialisation_UART(); /* Timer de type C (timer3) */ T3CON = 0x0000; // Active le timer avec le boutton 1 T3CONbits.TSIDL = 0; T3CONbits.TCS = 0; // Select internal instruction cycle clock T3CONbits.TGATE = 0; // Disable Gated Timer mode T3CONbits.TCKPS = 0b11; // Select 1:256 Prescaler TMR3 = 0x0000; // Clear timer register //TMR3HLD = 0x0000; // Maintien de la valeur PR3 = 100; // Load the period value IPC2bits.T3IP = 7; // Set Timer 1 Interrupt Priority Level IFS0bits.T3IF = 0; // Clear Timer 1 Interrupt Flag IEC0bits.T3IE = 1; // Enable Timer1 interrupt T3CONbits.TON = 1; // Active le timer /*****************************************************************/ }
int main(void) { init_PORT(); init_EX_INTERRUPT(); init_TIMER(); init_ADC(); init_USART(); sei(); while(1) { } return 0; }
int main(void) { SystemInit(); SystemCoreClockUpdate(); led_init(); init_interupt(); init_pwm(pwm_pin_num, pwm_channel, period, 0); init_coil(); init_timer(); init_ADC(); init_timer(); #ifdef DEBUG_WEIGHT int a; for (a = 0; a < COUNT; a++) { temp[a] = 0; } #endif printf("Weight Meassure. clibration: %d \n Press Button 1 to calibrate \n", calibrate); delay_ms(5000); if (button_pressed_1) { calibrate = true; button_pressed_1 = false; printf("Device will be calibrated \n"); } else { printf("Stock calibration will be used bei Temperatur:%g \n",calibration_temp); calibrate = false; } while (1) { measure_button(); //Funktion zum Start der Messung delay_ms(5); catapult_button(); check_temperatur(MAX_TEMP); delay_ms(2000); // printf("%g\n",compute_temperatur()); } return 0; }
inline void init(){ // Global initializations uartComms.init(); init_PWM(); init_ADC(); rprintfInit(uartSendByte); // DEBUGprint init // init_DEBUGprint(); // rprintf("*I\n"); // Wait for Eeprom to become available eeprom_busy_wait(); startupDiagnostics(); }
int main(void) { init_PORT(); init_TIMER0(); init_TIMER(); init_EX_INTERRUPT(); init_ADC(); init_USART(); init_PWM(); sei(); while(1) { if(state>3) state = 3; } return 0; }
// == Program Code int main(int argc, char* argv[]) { // Initialisations programState = PROG_STATE_INIT; init_LCD(); init_ports(); init_EXTI(); init_NVIC(); init_ADC(); init_TIM14(); display(DISP_WELCOME, 0); programState = PROG_STATE_WAIT_FOR_SW0; // Infinite loop while (1) { __asm("nop"); } }
int main(void) { init_gpio(); /* Setup Timers */ init_timer_0A(); init_timer_0B(); // Default to theremin on startup turn_on_red_LED(); PWM_init(); init_ADC(); init_nvic(); init_pushButton(); while(1) {} }
int main(void) { range_select(); init_timer0(); init_ADC(); init_7Seg(); init_led(); while(1) { int r = 0; if(read_ADC()) r = calc_resist(read_ADC()); test_limits(r); printbuf(r); _delay_ms(150); } }
int main(void) { //lprintf("%d", 4); init_ADC(); init_timer3(); init_timer(); init_USART(calcUBRR(BAUD)); char * str = "Degrees\tIR Distance (cm)\tSonar Distance (cm)\n\n\r"; move_servo(0); char degrees = 0; while(1) { //send_pulse(); Transmit_String(str); sprintf(str, "%d\t%d\t%d\n\r", degrees, ir_distance(), time2dist(ping_read())); move_servo(degrees); degrees += 2; if(degrees > 180) break; } }
int main(void) { /* Variables */ uint16_t ad_value = 0; char ad_value_text[8]; init_LCD(); init_ADC(); DDRD = 0xFF; PORTD = 0; while(1) { ad_value = read_ADC(); itoa(ad_value,ad_value_text,10); LCDGotoXY(0,1); LCDstring((uint8_t*) ad_value_text, (uint8_t) strlen(ad_value_text)); } }
int main(void) { init_ADC(); // Schalte ADC ein // korrekte Parameterwerte eADCRUNMODE runmode = SINGLESHOT; // Eine Messung start_ADC(runmode); // Messung starten eADCRES res = BIT8; // Auflösung des Digitalwertes unsigned short result; result = read_ADC(res); // 512 bei 50 % bei 10 Bit // 128 bei 50 % bei 8 Bit stop_ADC(); unsigned long a = 835; unsigned long * p = &a; unsigned char b; b = ulong2bcd_unpk(p); // b=5 - richtig & a=83 - richtig // Sonderfall Parameter = 0 unsigned long a2 = 0; unsigned long * p2 = &a2; unsigned char b2; b2 = ulong2bcd_unpk(p2); // b2=0 - richtig & a2=0 - richtig unsigned char c; c = ulong2bcd_pk(89); // Wird 1000 1001 - richtig // inkorrekter Parameterwert unsigned char c2; c2 = ulong2bcd_pk(5); // Wird 0 - richtig unsigned char c3; c3 = ulong2bcd_pk(100); // Wird 0 - richtig while (1) { } }
int main() { init_board(); LED_TRIS = 0; blink(100000L, 10, 0); init_timer(512); init_PWM(); init_ADC(6); init_spi_slave(); spi_slave_set_handle_message(link_board_handle_message); TRISFbits.TRISF5 = 0; while(1) { blink(10000L, 1, 1); } }
//==================================================================== // MAIN FUNCTION //==================================================================== void main (void){ init_LCD(); init_GPIO(); //Get operating CLK freq RCC_ClocksTypeDef CLK; RCC_GetClocksFreq(&CLK); sysclock= (CLK.SYSCLK_Frequency)/((float)(pow(10,6))); //Sys clocks in MHz sprintf(lcdstring,"CLK %d MHz",sysclock); lcd_putstring(lcdstring); lcd_command(LINE_TWO); lcd_putstring("Servo Step Test, SW0"); //Init procedure waits for SW0 while(GPIO_ReadInputData(GPIOA)&GPIO_IDR_0){} lcd_command(CLEAR); init_ADC(); init_EXTI(); init_USART1(); init_TIM2(); init_TIM3(); init_TIM14(); init_TIM17(); for(;;){ while(TIM3OC2<=3800){ TIM3OC2++; TIM_SetCompare2(TIM3,TIM3OC2); for(int x=0;x<=255;x++){ for(int y=0;y<=255;y++){} } } lcd_command(CURSOR_HOME); sprintf(lcdstring,"ADC:%d ",(int) ADCval); lcd_putstring(lcdstring); lcd_command(LINE_TWO); sprintf(lcdstring,"TIM:%d ",(int) TIM2->CCR3);//TIMcmp); //TIM_SetCompare2(TIM3,(int)(64000*((0.9+1.1*ADCval/2047.0)/20.0))); lcd_putstring(lcdstring); } } // End of main
// Main App int main(void) { init_Hbridge(); // Setup the X-Y motors init_Interrupt0(); // Setup INT0 init_ADC(); // Setup ADC on channel 5 sei(); // Enable All Interrupts while(1) { while(operationMode == 0xff) { for(uint8_t i=1;i<=40;i=i+2) { x_axis_forward(i); y_axis_forward(i); x_axis_backward(i); y_axis_backward(i); } } } }
int main(void) { ubBufferIndex = 0; ubLastBufferIndex = 0; init_Osc(); init_PWM(); // PWM Setup init_ADC(); // ADC Setup init_DAC_Comparators(); init_T1(); TRISBbits.TRISB4 = 0; //RB4 as output TRISBbits.TRISB6 = 1; TRISBbits.TRISB7 = 1; // PTCONbits.PTEN = 1; // Enable the PWM // ADCONbits.ADON = 1; // Enable the ADC uiHeaderZeroCount = 0; IEC0bits.T1IE = 1; // uc_Main_Case_Index = 0; while(1) { }; }
int main(void){ //startLCD_Show_Credits(); //lcd_check_busy_flag(); //lcd_send_command( LCD_CLEAR ); //You can multiplex these pins by enabling and disabling the LCD display. //lcd_puts( "Lx = 15uH " ); //lcd_check_busy_flag(); //lcd_send_command( LCD_SET_CURSOR_POS | LCD_SECOND_LINE ); //lcd_puts( "Cx = 150uF" ); //lcd_check_busy_flag(); //_delay_ms(2000); //lcd_send_command( LCD_CLEAR ); //lcd_puts("Hello Jenn!"); uart_init(); stdout = &uart_tx; stdin = &uart_rx; init_ADC(); //Set Pin Directions //Lights Pin as output LIGHTS_SIGNAL_DIR |= (1 << LIGHTS_SIGNAL); //Start Button Pin as input START_BUTTON_DIR &= ~(1 << START_BUTTON); //Stop Button Pin as Input STOP_BUTTON_DIR &= ~(1 << STOP_BUTTON); //Buzzer Pin as Output BUZZER_DIR |= (1 << BUZZER); //Trip Switch Pin as Input TRIP_SWITCH_DIR &= ~(1 << TRIP_SWITCH_PIN); //LCD Led Pin as output LCD_LED_DIR |= (1 << LCD_LED_PIN); LCD_LED_PORT |= (1 << LCD_LED_PIN); //Turn it on static long reading; static bool btnStop = false; static bool tripSwitch = false; startLCD_Show_Credits(); displayBlink(3); while (1){ printf("Raw Reading: %d\t",read_ADC(0,&reading)); long mapped_reading = mapRange(0,1023,0,1800,reading); printf("Mapped Reading: %d\t",mapped_reading); display_Selection(mapped_reading); if(START_BUTTON_PIN & (1 << START_BUTTON) && mapped_reading > 0){ lcd_check_busy_flag(); lcd_send_command(LCD_CLEAR); lcd_puts(" STARTING "); displayBlink(2); long count = 0; _delay_ms(1000); //Turn on lights LIGHTS_SIGNAL_PORT |= (1 << LIGHTS_SIGNAL); bool lightsOn = true; for(count = mapped_reading;count >= 0;count--){ //Check for stop button if(STOP_BUTTON_PIN & (1 << STOP_BUTTON)){ lcd_check_busy_flag(); lcd_send_command(LCD_CLEAR); lcd_puts(" STOPPING "); btnStop = true; break; } //Pause if trip switch is high if(!(TRIP_SWITCH_PIN & (1 << TRIP_SWITCH))){ if(!lightsOn){ LIGHTS_SIGNAL_PORT |= (1 << LIGHTS_SIGNAL); } //If the the switch is still closed printf("UV Lights on for: %d more secs...\n",count); lcd_check_busy_flag(); lcd_send_command(LCD_CLEAR); lcd_puts(" Exposing "); lcd_check_busy_flag(); lcd_send_command(LCD_SET_CURSOR_POS | LCD_SECOND_LINE); char * zero = "0"; uint8_t mins = count / 60; uint8_t secs = count % 60; char minsStr[5]; char secsStr[5]; itoa(mins,minsStr,10); itoa(secs,secsStr,10); lcd_check_busy_flag(); lcd_puts(" "); if(mins <= 9){ lcd_check_busy_flag(); lcd_puts(zero); } lcd_check_busy_flag(); lcd_puts(minsStr); lcd_check_busy_flag(); lcd_puts(":"); if(secs <= 9){ lcd_check_busy_flag(); lcd_puts(zero); } lcd_check_busy_flag(); lcd_puts(secsStr); _delay_ms(1000); } else{ lightsOn = false; LIGHTS_SIGNAL_PORT &= ~(1 << LIGHTS_SIGNAL); //Tell user the lid is open printf("LID OPEN, CLOSE IT TO CONTINUE\n"); lcd_check_busy_flag(); lcd_send_command(LCD_CLEAR); lcd_puts(" LID OPEN "); lcd_check_busy_flag(); lcd_send_command(LCD_SET_CURSOR_POS | LCD_SECOND_LINE); lcd_puts(" PLEASE CLOSE IT "); //Increment Count to make up for this one count++; } } //Turn off lights LIGHTS_SIGNAL_PORT &= ~(1 << LIGHTS_SIGNAL); if(btnStop != true){ lcd_check_busy_flag(); lcd_send_command(LCD_CLEAR); lcd_puts(" FINISHED "); alarmSound(2); } else{ buzzerSound(13); btnStop = false; //reset the stop flag } displayBlink(2); } } return 0; }
int main(){ uint8_t data; uint8_t h_byte = 0; uint8_t l_byte = 0; int fd; if((fd = init_ADC()) < 0){ printf("Failed to open bus: %s\n", strerror(errno)); } clock_t uptime[20]; for(int i = 0; i < 20; i++){ uptime[i] = clock(); //uptime[i] = (long long unsigned)clock() / (CLOCKS_PER_SEC / 1000)); data = get_ADC_byte(fd); } printf("CLOCKS_PER_SECOND: %llu\n", CLOCKS_PER_SEC); for(int i = 0; i < 19; i++){ clock_t diff = uptime[i + 1] - uptime[i]; printf("Current time: %llu - data: %d %x\n", diff / (CLOCKS_PER_SEC / 1000), data, data); printf("Current time: %d - data: %d %x\n", diff / (CLOCKS_PER_SEC / 1000), data, data); } exit(0); while(1){ // Read in 2 bytes data = get_ADC_byte(fd); /* // Check for sync errors h_byte = (uint8_t)(data >> 8); l_byte = (uint8_t)(data); if((h_byte & ZERO_MASK) != 0){ // The first byte shouldn't be a high byte. if((l_byte & ZERO_MASK) != 0){ // There is most likely a missing byte. Throw out current data printf("Sync error: can't recover. Resyncing...\n"); continue; } else{ // It is possible that the second byte is supposed to be a high byte. // Try resyncing by reading one more byte printf("Sync error: resyncing...\n"); h_byte = l_byte; l_byte = get_ADC_byte(fd); } } */ printf("Data: %d\t%x\n", data, data); /* ** The sync code doesn't support error codes. The AVR doesn't send them anyways if((data = get_ADC(fd)) < 0) printf("Failed to read data: %s\n", strerror(errno)); else printf("Data: %d\n", data); */ } if(close(fd) < 0) printf("Failed to close file: %s\n", strerror(errno)); }
void main (void) { /*开硬件浮点*/ SCB->CPACR |=((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ uint16 flag; uint16 i,j; DisableInterrupts; LCD_init(1); Disp_single_colour(Black); LCD_PutString(10, 50,"Frequency: ", White, Black); LCD_PutString(145, 50," KHz", White, Black); LCD_PutString(10, 80,"Power: ", White, Black); LCD_PutString(145, 80," W", White, Black); LCD_PutString(10, 110,"Amplify: ", White, Black); LCD_PutString(165, 110,"Restrain: ", White, Black); init_ADC(); init_DAC(); init_DMA(); init_PDB(); init_PIT(); init_gpio_PE24(); EnableInterrupts; LPLD_LPTMR_DelayMs(100); flag = Result_flag; uint16 ShowAFlag = 0; uint16 ShowBFlag = 0; uint16 ShowCFlag = 0; arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize); while(1) { if( flag==Result_flag && Result_flag == 0) { if(++ShowAFlag<10) { for(j = 0;j<LENGTH;j++) testInput_x[j*2] = Result_A[j]; for(j = 0;j<LENGTH;j++) testInput_x[j*2+1] = 0; arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); /* Process the data through the Complex Magnitude Module for calculating the magnitude at each bin */ arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); testOutput[0] = 0; /* Calculates maxValue and returns corresponding BIN value */ arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); } else { ShowAFlag = 0; if(starfir !=2 ) LCD_Put_Float(100, 50,"",testIndex*40.0/2048, White, Black); } if(starfir == 1) { PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_A[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_A[j] = firOutput[j]; PTE24_O = 0; } flag = 1; } else if(flag==Result_flag && Result_flag == 1) { if(starfir !=2 ) { if(++ShowBFlag<10) { power = 0; for(i=0;i<LENGTH;i++) power+=((Result_B[i] - OFFEST)/1241.0)*((Result_B[i] - OFFEST)/1241.0)*90*MyDb/8.0; power = power/LENGTH; } else { ShowBFlag = 0; LCD_Put_Float(100, 80,"",power, White, Black); } } else { for(i = 0;i<160;i++) { FFT_RESULT_NEW[i] = testOutput[i*6]/FFT_VALUE; if(FFT_RESULT_NEW[i]>239) FFT_RESULT_NEW[i] = 239; } } // { // for(j = 0;j<LENGTH;j++) // testInput_x[j*2] = Result_B[j]; // for(j = 0;j<LENGTH;j++) // testInput_x[j*2+1] = 0; // // arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); // // /* Process the data through the Complex Magnitude Module for // calculating the magnitude at each bin */ // arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); // // testOutput[0] = 0; // /* Calculates maxValue and returns corresponding BIN value */ // arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); // } if(starfir == 1) { PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_B[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_B[j] = firOutput[j]; PTE24_O = 0; } flag = 2; } else if(flag==Result_flag && Result_flag == 2) { // // { // for(j = 0;j<LENGTH;j++) // testInput_x[j*2] = Result_C[j]; // for(j = 0;j<LENGTH;j++) // testInput_x[j*2+1] = 0; // // arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); // // /* Process the data through the Complex Magnitude Module for // calculating the magnitude at each bin */ // arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); // // testOutput[0] = 0; // /* Calculates maxValue and returns corresponding BIN value */ // arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); // } if(starfir == 1) { // PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_C[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_C[j] = firOutput[j]; // PTE24_O = 0; } if(starfir != 2) { if(++ShowCFlag<5) { } else { if(ShowMenu) { Disp_single_colour(Black); LCD_PutString(10, 50,"Frequency: ", White, Black); LCD_PutString(145, 50," KHz", White, Black); LCD_PutString(10, 80,"Power: ", White, Black); LCD_PutString(145, 80," W", White, Black); LCD_PutString(10, 110,"Amplify: ", White, Black); LCD_PutString(165, 110,"Restrain: ", White, Black); ShowMenu = 0; } LCD_Put_Float(100, 110,"",MyDb/0.5, White, Black); if(starfir) LCD_PutString(260, 110,"On ", White, Black); else LCD_PutString(260, 110,"Off", White, Black); } } else { if(ShowMenu) { Disp_single_colour(Black); ShowMenu = 0; } draw_fft(); } flag = 0; } } }