void myPwm() { // choose channel for pwm PWM_Channel(E_CHANNEL0); // pwm out enable Init_PWM(); }
void main(void) { DisableInterrupts; PLL_Init_64M(); UART_Init(); Init_Port(); Init_AD(); Init_PWM(); // LCD_init(); // LCD_clear(); // RST = 1; PAT_Init(); // PWMDTY23 =6300 ; // DDRA_DDRA7 = 1; EnableInterrupts; for(;;) { Mode(); // uart_putchar('a'); /* OutData[0] = (int16)(roadflag[2]); OutData[1] = (int16)(roadflag[3]); OutData[2] = (int16)(Steer); OutData[3] = (int16)(roadflag[1]); OutPut_Data(); */ // Ramp_Detection(); GetExpectSpeed(); Steer_PID(); stop_car(); //Motor(1800); } }
int Pwm1::_setupPwmOut(float frequency, float duty) { int i; mode = MODE_PWM; i=Init_PWM(PWM1SET,frequency); Set_duty(PWM1TIMCH,duty); return i; }
int Buzzer::_setupPwmOut(float frequency, float duty) { int i; mode = MODE_PWM; i=Init_PWM(BUZZERSET,frequency); Set_duty(BUZZERTIMCH,duty); return i; }
int16_t main(void) { /* Configure the oscillator for the device */ ConfigureOscillator(); /* Initialize IO ports and peripherals */ InitApp(); Init_PWM(); Init_QEI(); AtpInit(); motion_init(SendDone); SendBoardId(); // Petit blink kikou au démarrage int i; for (i = 0 ; i < 14 ; i++) { __delay_ms(50); led = led ^ 1; } SendBoardId(); //pour les AX12 responseReadyAX = 0; while (1){ if (odoBroadcast) { OnGetPos(); } __delay_ms(odoBroadcastDelay); } }
int Led3::_setupPwmOut(float frequency, float duty) { int i; mode = MODE_PWM; i=Init_PWM(LED3SET,frequency); Set_duty(LED3TIMCH,duty); return i; }
void Init_Peripherals(void) { Init_Ports(); Init_ADC_Pin(); Init_ADC0(); Init_ADC1(); Init_Sensor_Switch_Pin(); SPI1_Init(); Init_PWM(); }
void Init() { Init_switch(); Init_PWM(); Init_DBGU(); Init_timer0(); // Init_timer1(); Init_ADC(); Motor_Init(); return ; }
/******************************************************************************* * Function Name : Target_Init * Description : STM32各个模块初始化 * Input : None * Output : None * Return : None *******************************************************************************/ void Target_Init(void) { RCC_Configuration(); GPIO_config(); NVIC_Configuration(); TIM_Init(); Init_PWM(3600); //USART1_Configuration(); //USART2_Configuration(); //USART3_Configuration(); //I2C1_Configuration(); }
void init_hw(void){ //Init I2C bus i2c_init(I2C_ADDRESS,1); sei(); // sbi( DDR_IR, E_IR ); // Set IR Enable as Output // DDRB = E_IR; Init_PWM(); InitADC(ADC_REFERENCE_AVCC, ADC_PRESCALE_DIV8); // OCR1B = 0x01; // GREEN RGB[0] = 0xf9; // RED RGB[1] = 0xf9; // GREEN RGB[2] = 0xf9; // BLUE }
int main(void) { // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_8MHZ); SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0); Init_ADC(); Init_PWM(); Init_Timer(); Init_UART(); while (1) { } }
int main(void) { //SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_8MHZ); //8MHz SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //20MHz //SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //50Mhz Init_GPIO(); Init_PWM(); Init_UART(); Init_Timer(); Init_ADC(); while (1) { } }
int main(void) { /*SysCtlClockSet( SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);*/ SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //20MHz SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0); Init_Timer_a(); Init_Timer_b(); Init_PWM(); unsigned long ulValue; // // Enable the first sample sequence to capture the value of channel 0 when // the processor trigger occurs. // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); //Will use ADC ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_CH0); ADCSequenceEnable(ADC_BASE, 0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); // // Trigger the sample sequence. // ADCProcessorTrigger(ADC_BASE, 0); // // Wait until the sample sequence has completed. // while (!ADCIntStatus(ADC_BASE, 0, false)) { } // // Read the value from the ADC. // ADCSequenceDataGet(ADC_BASE, 0, &ulValue); while (1) { } }
/* * Start the demo application tasks - then start the real time scheduler. */ int main( void ) { /* Setup the hardware ready for the demo. */ prvSetupHardware(); vParTestInitialise(); Init_PWM(); if ((xEventGroup = xEventGroupCreate()) != NULL) { /* Start the standard demo application tasks. */ vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); xTaskCreate( vCommTask, "nRF", configMINIMAL_STACK_SIZE*3, NULL, mainComm_TASK_PRIORITY, ( TaskHandle_t * ) NULL ); xTaskCreate( vMPDTask, "mpu", configMINIMAL_STACK_SIZE*3, NULL, mainMPU_TASK_PRIORITY, ( TaskHandle_t * ) NULL ); /* Start the scheduler. */ vTaskStartScheduler(); } vParTestSetLED(7, 1); while(1); /* As the scheduler has been started the demo applications tasks will be executing and we should never get here! */ return 0; }
int main(void) { //***************************************************************************************// //*****************ARRANCAMOS LA CONFIGURACION DEL PIC **********************************// //***************************************************************************************// Init_Hw(); Delay1msT1(0); //Configuramos el puertos y quitamos analogicos Init_Pll(); Delay1msT1(0); //configuramos el pll que abiasmos arracamos sin él Init_PWM(); Delay1msT1(0); //configuramos el PWM init_interr_extern(); Delay1msT1(0); //configuramos las interrupciones externas Init_Bluetooh(); Delay1msT1(0); //Configuramos el serial-Bluetooth cargar_datos_ajuste(); Init_I2C(); Delay1msT1(0); //incializamos el I2c set_inicial(); Delay1msT1(0); //Configuramos la incialicacion de sensor getAngle_init(); Delay1msT1(0); //Incializamos el filtro kalman set_inicial(); Delay1msT1(0); //Incializamos el acelerometro LED_ALL_ON(); for (i = 0; i < 2500; i++) Delay_Nop(2000); LED_ALL_OFF(); //***************************************************************************************// //***************************************************************************************// //*****************CALIBRAMOS EL ACELEROMETRO Y GIROSCOPO *******************************// // get_calibrado_acelerometro(5, 50); //cojemos los valres por defecto del giroscopo y aceletometro LED_ALL_OFF(); //***************************************************************************************// //*****************INICIALIZAMOS EL PID Y LAS VARIABLES ********************************// // pid_dsp_configuracion(); //***************************************************************************************// LED_ALL_OFF(); //*****************ARRANCAMOS INTERRUPCION DEL BUCLE PRINCIPAL *************************// SetupT3ForXmsPID(Tsample); //configuramos la interrupcion principal SetupT4For20msPID(); //configuramos la interrupcion principal StartInterrup4(); //incializamos la interrupcion StartInterrup3(); //incializamos la interrupcion enviar_mensaje("------------------------------------------------------"); //***************************************************************************************// while (1) { } }
void myPwm() { PWM_Channel(E_CHANNEL0); // Select PWM channel. Init_PWM(); // Enable PWM function and set PWM period. }
int main () { char bar = '-'; ReloadXML = 1; int ActionId; pthread_t LightThread; pthread_t MusicThread; pthread_t CheckXMLModificationThread; GetXMLModificationDate(&LastXMLModificationDate); pthread_create (&CheckXMLModificationThread, NULL, CheckXMLModification, &bar); while(1) { sleep(1); if( ReloadXML ) { ReloadXML = 0; pthread_cancel (MusicThread); pthread_join (MusicThread, NULL); pthread_cancel (LightThread); pthread_join (LightThread, NULL); memset(TimedActions, 0, sizeof(TimedActions)); NoOfActions = ReadXML(); InvertedPWM = 0; PWMFrequency = 200; // Default 200 Hz for(ActionId=0; ActionId<NoOfActions; ActionId++) { if( !strcmp(TimedActions[ActionId].PWM_Inverted, "true") ) InvertedPWM = 1; if( atoi(TimedActions[ActionId].PWM_Frequency) != 0 ) PWMFrequency = atoi(TimedActions[ActionId].PWM_Frequency); } Init_PWM(); SetPWMValue(0); Audio_SetVolume(0); Audio_Stop(); /* PrintTimedAction(&TimedActions[0]); PrintTimedAction(&TimedActions[1]); PrintTimedAction(&TimedActions[2]); PrintTimedAction(&TimedActions[3]);*/ } CheckForcedAction(); ActionId = CheckEnable(); if( ActionId >= 0 ) { if( !strcmp(TimedActions[ActionId].Type, "TimedAction_PWM") ) pthread_create (&LightThread, NULL, DimmUp, &TimedActions[ActionId]); if( !strcmp(TimedActions[ActionId].Type, "TimedAction_Music") ) pthread_create (&MusicThread, NULL, Music, &TimedActions[ActionId]); } } return 0; }
//*-------------------------------------------------------------------------------------- //* Function Name : Main //* Object : Software entry point //* Input Parameters : none. //* Output Parameters : none. //*-------------------------------------------------------------------------------------- int main(void) { char data[MSG_SIZE]; unsigned int length; int stepCnt = 0; unsigned char str[10]; /**** System init ****/ //InitFrec(); Init_CP_WP(); //chek for CP and WP //CP - card present while(((AT91C_BASE_PIOA->PIO_PDSR) & BIT15)) { /*put your card present event here*/ } //WP - write protect //while(((AT91C_BASE_PIOA->PIO_PDSR) & BIT16)) { /*put your write protect event here*/ } if (initMMC() == MMC_SUCCESS) { //card_state |= 1; memset(&mmc_buffer,0,512); mmcReadRegister (10, 16); mmc_buffer[7]=0; } flashInit(); Init_PWM(); // Enable User Reset and set its minimal assertion to 960 us AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4<<8) | (unsigned int)(0xA5<<24); // Led init // First, enable the clock of the PIOB AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ; //* to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only. AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, OUTPUT_MASK ); //* Clear the LED's. /* AT91F_PIO_SetOutput( AT91C_BASE_PIOA, OUTPUT_MASK ); AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, OUTPUT_MASK ); */ // Init USB device AT91F_USB_Open(); AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, OUTPUT_MASK ); // Init USB device // Wait for the end of enumeration setForce(40000); int pCDCEnablingCounter = 0; while (!pCDC.IsConfigured(&pCDC) && pCDCEnablingCounter < 2500000){ pCDCEnablingCounter++; }; if (pCDCEnablingCounter < 2500000) { CDC = 1; } setForce(0); // Set Usart in interrupt //Usart_init(); //Read and set settings memcpy(settings, OUR_FLASH_ADDR, 128); int i;memset(&mmc_buffer, 0x00, 512); int j; char *settingsBlocks[50]; char settingsDelim[] = "~"; char *settingsParts = strtok( settings, settingsDelim ); i = 0; while( settingsParts != NULL ) { settingsBlocks[i++] = settingsParts; settingsParts = strtok( NULL, settingsDelim ); } for (j = 0; j < i; j++) { parseSettings(settingsBlocks[j]); } InitADC(); Init_PWM(); AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SW1_MASK); AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SW2_MASK); AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_GREEN); AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_YELLOW); setForce(0); //startBlinking(250000); /**** MMC CARD ****/ init_extint(); while (1) { cnt++; if (cnt > 50000) { cnt = 0; printTrace("COUNTER RESET\n"); } } }
/****************************************************************** Main ******************************************************************/ int main(void) { /*Disable watchdog*/ RCONbits.SWDTEN = 0; set_clk(); InitIO(); //Initialize CAN communication initialisation_CAN(); //Initialize PWM (Motor Control) Init_PWM(); //Initialize ADC //Init_ADC(); //Initialize QEI (Speed/Position DC motor) InitQEI(); chinookpack_unpacked_init(&unpacker); #ifdef memory_init /*Retrieve Last gear and mât position*/ do{ EEPROM_REQUEST = 0x55; envoi_CAN_periodique_init(); last_gear = datReceive_can_EEPROM_CONFIG_ANSWER_gear; last_position_mat = datReceive_can_EEPROM_CONFIG_ANSWER_mat; }while(datReceive_can_EEPROM_CONFIG_ANSWER_mat==190.0f); gear = last_gear; Position_mat = last_position_mat; char print[80]; sprintf(print,"last gear: %d \t last position mat : %f \r",last_gear,last_position_mat); char u=0; do { U1TXREG=print[u]; while(U1STAbits.TRMT!=1); u++; }while(print[u]!=0); int k=0; do{ EEPROM_REQUEST = 0xAA; envoi_CAN_periodique_init(); k++; }while(k<5); #endif /*Enable 24V supply switch*/ ENALIM = 1; //envoi_CAN_periodique(); //envoi_CAN_periodique(); //Transmission goes to first gear Stepper_Shift_Init(last_gear); //Mat goes to origin //Init_mat(last_position_mat); while(1) { //Transmission goes to first gear if(datReceive_can_conf) Stepper_Shift_Init(last_gear); Stepper_Shift(); envoi_CAN_periodique(); #ifdef mat_manuel if(!datReceive_can_cmd[0]) { if(last_cmd_mat == 14 || last_cmd_mat == 15){ cmd_mat=datReceive_can_cmd[3]|datReceive_can_cmd[2]|datReceive_can_cmd[1]|datReceive_can_cmd[0]; } if(last_cmd_mat == 11){ delai_mat++; cmd_mat = 0; if(delai_mat<60000) tower_motor_ctrl(&PDC1,Position_mat); else if(delai_mat>=60000) delai_mat = 0; } } else if(!datReceive_can_cmd[2]) { if(last_cmd_mat == 11 || last_cmd_mat == 15){ cmd_mat=datReceive_can_cmd[3]|datReceive_can_cmd[2]|datReceive_can_cmd[1]|datReceive_can_cmd[0]; } if(last_cmd_mat == 14){ cmd_mat = 0; delai_mat++; if(delai_mat<60000) tower_motor_ctrl(&PDC1,Position_mat); else if(delai_mat>=60000) delai_mat = 0; } } else //if(datReceive_can_cmd == 15) { cmd_mat=15; } if(cmd_mat ==14) { last_cmd_mat = cmd_mat; LED0^=1; tower_motor_ctrl(&PDC1,-180.0f); } else if(cmd_mat == 11) { last_cmd_mat = cmd_mat; tower_motor_ctrl(&PDC1,180.0f); } else if(cmd_mat == 15) { last_cmd_mat = cmd_mat; tower_motor_ctrl(&PDC1,Position_mat); } #endif #ifdef mat_test tower_motor_ctrl(&PDC1,-90.0f); #endif #ifdef mat_auto tower_motor_ctrl(&PDC1,datReceive_can_wind_direction); #endif } }
void main(void) { int8u dec_key; OSCTUNE = 0; OSCCON = 0b01100011;//0b01110011; //TRISA = 0b11000001; //TRISE = 0; //TRISC = 0b0111; TRISA=0b11000001; //TRISAbits.RA6=1; //TRISAbits.RA7=1; TRISC=0b0111; TRISE=0b000000000; TRISB7=0; TRISD3=0; TRISD2=0; TRISD1=0; TRISD0=1; TRISB0=0; TRISB1=0; TRISD4=0; TRISD5=0; TRISD6=0; TRISD7=0; USARTinit(); lcd_init(); Initcustom_char(); cur_gain = 0.25; /*strncpy( Lcd_LINE1 , Lcd_L1 , 16 ) ; strncpy( Lcd_LINE2 , Lcd_L2 , 16 ) ; Display(); strncpy( Lcd_LINE1 , Lcd_L3 , 16 ) ; strncpy( Lcd_LINE2 , Lcd_L4 , 16 ) ; Display();*/ //while(1); Adc_init(); Init_i2c(); Init_stat_isr(); Init_PWM(); dutyvolt = 0; dutycurrent = 0; Set_PWM_Duty(); /*while(1) { Display(); USARTWriteChar('U'); USARTWriteString(" Hi All\n\r"); dec_key = getkey();dispnum( dec_key ,1,2); Get_ADC_Count(); dispnum( ADC_Count,5,7); DelayMs(1000); }*/ FFT_ready_flag = 0; while(1) { if(FFT_ready_flag) { INT0IE = 0; Read_FFT(0,128); FFT_ready_flag = 0; Calc_percentageFull(); Disp_Mill_fill(); INT0IE = 1; } } }