void ADC1_Init(void) { INIT_ADC_GPIO(); ADC_DMA_Init(); ConfigADC(); timer3_init(500,(72-1));//500 memset(&adc_param,0,sizeof(adc_param)); ADC1_DMA_Start(); }
int main (void) { i = 0; initialise_buffer(); INIT_IT(); LEDS_B_INIT(); ConfigTIM2(); ConfigADC(); configure_dac(); TIM2->CR1 |= 0x01; while (1) //Boucle Infini { } }
void TemperatureTask(void * parameters) { double average; //char string[16]; //LCDMessage_t * Message; TemperatureTaskData_t * Data = (TemperatureTaskData_t * )parameters; ConfigADC(); while(1) { IFS0bits.AD1IF = 0; AD1CON1bits.SAMP = 1; while(IFS0bits.AD1IF < 1) Nop(); average = RemoveOutliersAverage(); Data->Volts = average/4096.0 * 3.3; Data->Kelvin = Data->Volts * 2 * 100; Data->Celsius = Data->Kelvin - 273.15; Data->Fahrenheit = 32 + 1.8 * Data->Celsius; /* Message = CreateWriteLineLCDMessage(string, sprintf(string,"Volts: %.3f",Data->Volts),0); MessageSend(Data->LCDQueue,&Message,0); Message = CreateWriteLineLCDMessage(string, sprintf(string,"Temp: %.1f",Data->Fahrenheit),1); MessageSend(Data->LCDQueue,&Message,0); */ vTaskDelay(8000); } }
void main(void) { // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the F2806x_SysCtrl.c file. char * rto1 = (char *)0x8000; for (rn1 = 0; rn1 < nn1; rn1++) *rto1++ = rfrom1; memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize); InitSysCtrl(); // Step 2. Initalize GPIO: // This example function is found in the F2806x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Skipped for this example // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the F2806x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in F2806x_DefaultIsr.c. // This function is found in F2806x_PieVect.c. InitPieVectTable(); // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.EPWM5_INT = &epwm5_timer_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Step 4. Initialize all the Device Peripherals: // This function is found in F2806x_InitPeripherals.c // InitPeripherals(); // Not required for this example InitAdc(); // For this example, init the ADC //InitAdcAio(); // Function that sets analog input pins ConfigADC(); //AdcOffsetSelfCal(); InitEPwm(); // Function initializes ePWM 1 - 5 // Step 5. User specific code, enable interrupts: // Copy time critical code and Flash setup code to RAM // This includes the following ISR functions: epwm1_timer_isr(), epwm2_timer_isr() // epwm3_timer_isr and and InitFlash(); // The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart // symbols are created by the linker. Refer to the F2808.cmd file. // Call Flash Initialization to setup flash waitstates // This function must reside in RAM InitFlash(); IER |= M_INT3; // Enable CPU INT3 which is connected to EPWM1-8 INT: page 175 in documentation IER |= M_INT10; // Enable CPU Interrupt 10 // Enable EPWM INTn in the PIE: Group 3 interrupt 1-3 PieCtrlRegs.PIEIER3.bit.INTx5 = PWM5_INT_ENABLE; // Enable ADCINT1 in PIE /*PieCtrlRegs.PIEIER10.bit.INTx1 = 1; // Enable INT 10.1 in the PIE PieCtrlRegs.PIEIER10.bit.INTx2 = 1; // Enable INT 10.2 in the PIE PieCtrlRegs.PIEIER10.bit.INTx3 = 1; // Enable INT 10.3 in the PIE PieCtrlRegs.PIEIER10.bit.INTx4 = 1; // Enable INT 10.4 in the PIE PieCtrlRegs.PIEIER10.bit.INTx5 = 1; // Enable INT 10.5 in the PIE PieCtrlRegs.PIEIER10.bit.INTx6 = 1; // Enable INT 10.6 in the PIE PieCtrlRegs.PIEIER10.bit.INTx7 = 1; // Enable INT 10.7 in the PIE PieCtrlRegs.PIEIER10.bit.INTx8 = 1; // Enable INT 10.8 in the PIE*/ // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // Step 6. IDLE loop. Just sit and loop forever (optional): EALLOW; GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 0; GpioCtrlRegs.GPBDIR.bit.GPIO54 = 1; GpioDataRegs.GPBCLEAR.bit.GPIO54 = 1; EDIS; for(;;) { // This loop will be interrupted, so the overall // delay between pin toggles will be longer. DELAY_US(DELAY); LoopCount++; //GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; } }