int main() { // unsigned char onechar = 'a'; PLL_Init(); PortA_Init(); PortC_Init(); SysTick_Init(); Nokia5110_Init(); // Зеленый светодиод выкл, PC9. Синий сетодиод вкл, PC8. Положительная логика GPIOC_BSRR = 0x2000100; Nokia5110_Clear(); while(1){ if((GPIOA_IDR & 0x1)){ // Проверяем нажатие кнопки, PA0. Положительная логика GPIOC_BSRR = 0x1000200; // Синий LED off. Зеленый LED on SysTick_Wait10ms(20); // задержка 200 мс GPIOC_BSRR = 0x3000000; // Синий LED off. Зеленый LED off SysTick_Wait10ms(20); // задержка 200 мс Nokia5110_OutString("Hello,World!"); } else GPIOC_BSRR = 0x2000100; // Синий светодиод вкл. Зеленый сетодиод выкл } }
int main(void) { PLL_Init(); SysFun(); // 80 MHz PortA_Init() ; // initialize output and interrupts EnableInterrupts(); /*Initialize ports and timers*/ while(1){ unsigned long i,j; for(i=80000; i<=160000; i+=16000) /*on time starts from 1msec to 2msec with a increment of 0.2msec risein on tim */ { for(j=0;j<4;j++) { GPIO_PORTA_DATA_R |= (0x40); SysLoad(i); GPIO_PORTA_DATA_R &= ~(0x40); SysLoad(1600000-i); } } for(i=160000; i>=80000; i-=16000) { for(j=0;j<4;j++) { GPIO_PORTA_DATA_R |= (0x40); SysLoad(i); GPIO_PORTA_DATA_R &= ~(0x40); SysLoad(1600000-i); } } } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PLL_Init(); // 80 MHz Port_Init(); ADC0_InitSWTriggerSeq3_Ch1(); EnableInterrupts(); SysFun(); /*Initialize ports , ADC and timers*/ while(1){ /*Your code goes here*/ a= ADC0_InSeq3(); t1=a+(10000/4096)+10000; in1=50; while(in1) { GPIO_PORTA_DATA_R |= (0x20); SysLoad(t1); GPIO_PORTA_DATA_R &= ~(0x20); SysLoad(t-t1); in1=in1-1; } } }
//------------main---------------------------- int main(void){ PLL_Init(); SysTick_Init(); Switch_Init(); Output_Init(); // print intro screen to lab printf(" Fixed-point Lab\n"); printf("\n\n\n\n\n\n\n\n\n\n"); printf(" By:\n"); printf(" Brandon Boesch\n"); printf(" Curtis Martin\n"); printf(" Press SW2 to begin\n"); ST7735_DrawBitmap(30, 108, bmp_Logo, 70, 100); // begin tests while(PF0 == 0x01){}; Fixed_uDecOut2_test(); while(PF0 == 0x01){}; Fixed_sDecOut3_test(); while(PF0 == 0x01){}; Fixed_uBinOut8_test(); while(PF0 == 0x01){}; // outro screen Output_Clear(); ST7735_SetCursor(0,0); printf("Tests complete!"); ST7735_DrawBitmap(6, 159, bmp_thumbs, 114, 146); while(1){}; }
int main(void) { unsigned long input= 0; PLL_Init(); Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done while(1) { // input from keys to select tone input= Piano_In(); switch (input) { case 0x01: Sound_Tone(C); break; case 0x10: Sound_Tone(D); break; case 0x04: Sound_Tone(E); break; case 0x08: Sound_Tone(G); break; default: Sound_Off(); break; } } }
int main(){ int i = 0; PLL_Init(); SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // 50 MHz DisableInterrupts(); SYSCTL_RCGC1_R |= SYSCTL_RCGC1_TIMER0;// activate timer0 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF+SYSCTL_RCGC2_GPIOG; // activate ports F and G Output_Init(); SysTick_InitSeconds(1); PolledButtons_Init(); EnableInterrupts(); displayMode = 0; ringAlarms = 0; timeMode = 0; while(1){ if (ringAlarms && !soundPlaying && (alarmActive || timeMode == 4)) { playSound(); } else if ((ringAlarms==0 || !alarmActive) && soundPlaying) { stopSound(); } if(displayMode==0) { displayClock(); } else if(displayMode==1){ displaySet(); } } }
int main1(void){ PLL_Init(); ST7735_InitR(INITR_REDTAB); while(1){ plotImage(); } }
int main(void){uint32_t i; PLL_Init(Bus80MHz); PortF_Init(); ST7735_InitR(INITR_REDTAB); while(1){ ST7735_FillScreen(0); // set screen to black ST7735_SetCursor(0,0); printf("Lab 1\rST7735_sDecOut3\r"); for(i=0; i<13; i++){ ST7735_sDecOut3(outTests1[i].InNumber); // your solution ST7735_OutString((char*)outTests1[i].OutBuffer); // expected solution } //Pause(); ST7735_FillScreen(0); // set screen to black ST7735_SetCursor(0,0); printf("ST7735_uBinOut8\r"); for(i=0; i<14; i++){ ST7735_uBinOut8(outTests2[i].InNumber); // your solution ST7735_OutString((char*)outTests2[i].OutBuffer); // expected solution } //Pause(); ST7735_XYplotInit("Circle",-2500, 2500, -2500, 2500); ST7735_XYplot(180,(int32_t *)CircleXbuf,(int32_t *)CircleYbuf); //Pause(); ST7735_XYplotInit("Star- upper right",-450, 150, -400, 200); ST7735_XYplot(50,(int32_t *)StarXbuf,(int32_t *)StarYbuf); Pause(); } }
int main(void){ DisableInterrupts(); PLL_Init(Bus80MHz); // bus clock at 80 MHz UART_Init(); ST7735_InitR(INITR_REDTAB); ADC0_InitTimerTriggerSeq3_Ch0(); EnableInterrupts(); /* UART_OutString("Points: \r\n"); while(currentIndex < 100); for(int i = 0; i < 100; i += 1) { UART_OutUDec(data[i]); UART_OutString("\r\n"); } */ while(1) { ST7735_SetCursor(0, 0); int32_t currentTemperature = Temperature_Convert(ADC_FIFO_CurrentValue()); printf("Temperature %5d.%02d\n", currentTemperature / 100, currentTemperature % 100); ST7735_PlotClear(32, 159); //TODO change color? for(int i = 0; i < FIFO_SIZE; i += 1) { int32_t point = 128 - Temperature_Convert(ADC_FIFO_Get()[i]) * 2 / 100; ST7735_DrawPixel(i+1, point+1, ST7735_RED); ST7735_DrawPixel(i+1, point, ST7735_RED); ST7735_DrawPixel(i, point+1, ST7735_RED); ST7735_DrawPixel(i, point, ST7735_RED); } WaitForInterrupt(); } }
int main(void){ uint32_t count = 0; PLL_Init(); // set system clock to 50 MHz Nokia5110_Init(); Nokia5110_Clear(); for(count=0; count<1; count=count+1){ Nokia5110_DrawFullImage(Longhorn); Delay(16666667); // delay ~1 sec at 50 MHz Nokia5110_DrawFullImage(Longhorn2); Delay(16666667); // delay ~1 sec at 50 MHz } // count = 0; Nokia5110_Clear(); // Nokia5110_OutString("************* LCD Test *************Letter: Num:------- ---- "); //Nokia5110_OutChar(127); // print UT sign while(1){ Nokia5110_SetCursor(0,0); Nokia5110_OutString("Hello World"); Nokia5110_OutString(" bright future"); Delay(8333333); // delay ~0.5 sec at 50 MHz //count = count + 1; } }
//debug code int main(void){ PLL_Init(Bus80MHz); // bus clock at 50 MHz Output_Init(); SYSCTL_RCGCGPIO_R |= 0x20; // activate port F //ADC0_InitTimer0ATriggerSeq3(2, F30HZ); // ADC channel 0, 1000 Hz sampling ADC0_InitTimer0ATriggerSeq3PD3(F30HZ); //ADC0_InitSWTriggerSeq3_Ch9(); while((SYSCTL_PRGPIO_R&0x0020) == 0){};// ready? GPIO_PORTF_DIR_R |= 0x02; // make PF1 output (PF1 built-in LEDs) GPIO_PORTF_AFSEL_R &= ~0x02; // disable alt funct on PF1 GPIO_PORTF_DEN_R |= 0x02; // enable digital I/O on PF1 // configure PF1 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF EnableInterrupts(); plotInit(); while(1){ GPIO_PORTF_DATA_R ^= 0x02; // toggle LED //ADCvalue = ADC0_InSeq3(); temperature = adcToTemp(ADCvalue + offset); plotPoint(); ST7735_SetCursor(1,2); ST7735_sDecOut2(temperature); ST7735_SetCursor(2,1); ST7735_OutUDec(ADCvalue + offset); } }
//debug code int main(void){ char ch; char string[20]; // global to assist in debugging uint32_t n; PLL_Init(Bus50MHz); // 50 MHz UART_Init(); // initialize UART OutCRLF(); for(ch='A'; ch<='Z'; ch=ch+1){// print the uppercase alphabet UART_OutChar(ch); } OutCRLF(); UART_OutChar(' '); for(ch='a'; ch<='z'; ch=ch+1){// print the lowercase alphabet UART_OutChar(ch); } OutCRLF(); UART_OutChar('-'); UART_OutChar('-'); UART_OutChar('>'); while(1){ UART_OutString("InString: "); UART_InString(string,19); UART_OutString(" OutString="); UART_OutString(string); OutCRLF(); UART_OutString("InUDec: "); n=UART_InUDec(); UART_OutString(" OutUDec="); UART_OutUDec(n); OutCRLF(); UART_OutString("InUHex: "); n=UART_InUHex(); UART_OutString(" OutUHex="); UART_OutUHex(n); OutCRLF(); } }
// ******** OS_Init ************ // initialize operating system, disable interrupts until OS_Launch // initialize OS controlled I/O: systick, 50 MHz PLL // input: none // output: none void OS_Init(void){ OS_DisableInterrupts(); PLL_Init(); // set processor clock to 50 MHz NVIC_ST_CTRL_R = 0; // disable SysTick during setup NVIC_ST_CURRENT_R = 0; // any write to current clears it NVIC_SYS_PRI3_R =(NVIC_SYS_PRI3_R&0x00FFFFFF)|0xE0000000; // priority 7 }
int main(void){ Output_Init(); // ST7735_XYplotInit("Temp", 0, 100, 0, 100); PLL_Init(Bus80MHz); // 80 MHz SYSCTL_RCGCGPIO_R |= 0x20; // activate port F ADC0_InitSWTriggerSeq3_Ch9(); // allow time to finish activating Timer0A_Init100HzInt(); // set up Timer0A for 100 Hz interrupts GPIO_PORTF_DIR_R |= 0x06; // make PF2, PF1 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x06; // disable alt funct on PF2, PF1 GPIO_PORTF_DEN_R |= 0x06; // enable digital I/O on PF2, PF1 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF PF2 = 0; // turn off LED EnableInterrupts(); ST7735_SetCursor(6,0); printf("C"); ST7735_SetCursor(13,0); printf("ADC"); while(1){ PF1 ^= 0x02; // toggles when running in main temperature = adcToTemp(ADCvalue); ST7735_SetCursor(0,0); ST7735_sDecOut2(temperature); ST7735_SetCursor(9,0); ST7735_OutUDec(ADCvalue); } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PLL_Init(); // 80 MHz EnableInterrupts(); /*Initialize ports , ADC and timers*/ ADC0_InitSWTriggerSeq3_Ch1(); PortA_Init(); //SysLoad(T); SysFun(); while(1){ /*Your code goes here*/ value=ADC0_InSeq3(); //PWMindex=(ADCvalue); p=((value+1)*390)+800000; //for(i=0;i<4;i++){ GPIO_PORTA_DATA_R|=0x20; SysLoad(p); GPIO_PORTA_DATA_R&=~0x20 ; SysLoad(T-p); //} } }
int main(void){unsigned short score; PLL_Init(); // Set the clocking to run at 80MHz from the PLL. LCD_Init(); // Initialize LCD LCD_Goto(0,0); score =0; long v2; LCD_SetTextColor(255,0,0); // yellow= red+green, no blue printf("score: %d", score); LCD_DrawLine(10,16,310,16,BURNTORANGE); Timer2_Init(4000000); // 20 times a second Timer3_Init(7256); // 11.025 KHz InitEnemy(); InitBunker(); InitPlayer(); InitMissile(); InitLaser(); Random_Init(1); EnableInterrupts(); Fireflag=1; while(1){ if(Semaphore){ DrawBuffer1(); Semaphore = 0; } } }
void main(void){ PLL_Init(); // running at 24MHz DDRT |= 0x1F; // debugging outputs PTT &= ~0x1F; Debug_Profile(0); // 0 means initialization phase Fifo_Init(); // Initialize fifo OC0_Init(); // variable rate interrupt ForeExpected = 0; // expected data for(;;){ Debug_Profile(1); // 1 means start of foreground waiting PTT_PTT1 = 0; // falling edge of PT1 means start of foreground waiting while(Fifo_Get(&ForeData)==FIFOFAIL){ } Debug_Profile(2); // 2 means foreground has new data PTT_PTT1 = 1; // rising edge of PT1 means start of foreground processing if(ForeExpected != ForeData){ Errors++; PTT ^= 0x10; // critical section found ForeExpected = ForeData+1; // resych to lost/bad data } else{ ForeExpected++; // sequence is 0,1,2,3,...,254,255,0,1,... } if((ForeData%10)==0){ Debug_Profile(3); // 3 means foreground has 10th data } } }
int main(void){ uint8_t n; // state number uint32_t Input; PLL_Init(Bus80MHz); // initialize 50 MHz system clock SysTick_Init(); // initialize SysTick timer SYSCTL_RCGCGPIO_R |= 0x12; // activate clock for Port E and Port B // allow time for clock to stabilize while((SYSCTL_PRGPIO_R&0x12) == 0){}; GPIO_PORTB_DIR_R |= 0x3F; // make PB5-0 out GPIO_PORTB_AFSEL_R &= ~0x3F; // disable alt funct on PB5-0 GPIO_PORTB_DEN_R |= 0x3F; // enable digital I/O on PB5-0 // configure PB5-0 as GPIO GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R&0xFF000000)+0x00000000; GPIO_PORTB_AMSEL_R &= ~0x3F; // disable analog functionality on PB5-0 GPIO_PORTE_DIR_R &= ~0x03; // make PE1-0 in GPIO_PORTE_AFSEL_R &= ~0x03; // disable alt funct on PE1-0 GPIO_PORTE_DEN_R |= 0x03; // enable digital I/O on PE1-0 // configure PE1-0 as GPIO GPIO_PORTE_PCTL_R = (GPIO_PORTE_PCTL_R&0xFFFFFF00)+0x00000000; GPIO_PORTE_AMSEL_R &= ~0x03; // disable analog functionality on PE1-0 n = goN; // initial state: Green north; Red east while(1){ LIGHT = FSM[n].Out; // set lights to current state's Out value SysTick_Wait10ms(FSM[n].Time); // wait 10 ms * current state's Time value Input = SENSOR; // get new input from car detectors n = FSM[n].Next[Input]; // transition to next state } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PLL_Init(); // 80 MHz // initialize output and interrupts SysInit(); Port_Init(); // EnableInterrupts(); /*Initialize ports and timers*/ while(1) { for(j=80000;j<=160000;j=j+8000) { for(k=0;k<=3;k++) { GPIO_PORTA_DATA_R|=0x20; SysLoad(j); GPIO_PORTA_DATA_R&=~(0x20); SysLoad(1600000-j); } } } }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PLL_Init(); // 80 MHz Sound_Init(); // initialize output and interrupts EnableInterrupts(); while(1){ // interrupts every 500us WaitForInterrupt(); } }
/********************************************************** Description : Initialization configuration Input : None Output : None ***********************************************************/ void INTConfig(void) { WacthDogRestart(); PLL_Init(); EMI_Setting(); }
int main(void){ char* lab9greeting = "Welcome to Lab 9!"; int temp; // int Temperature = 100; // DisableInterrupts(); // PLL_Init(Bus80MHz); // //ST7735_InitR(INITR_REDTAB); // Output_Init(); // UART0 only used for debugging // ST7735_Output_Init(); // ADC0_InitSWTriggerSeq3_Ch9(); //initialize the ADC // Timer0A_Init20HzInt(); //initialize the timer // ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE); // EnableInterrupts(); PLL_Init(Bus80MHz); // 80 MHz SYSCTL_RCGCGPIO_R |= 0x20; // activate port F ADC0_InitSWTriggerSeq3_Ch9(); // allow time to finish activating Timer0A_Init20HzInt(); // set up Timer0A for 100 Hz interrupts GPIO_PORTF_DIR_R |= 0x06; // make PF2, PF1 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x06; // disable alt funct on PF2, PF1 GPIO_PORTF_DEN_R |= 0x06; // enable digital I/O on PF2, PF1 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF PF2 = 0; // turn off LED ST7735_Output_Init(); ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE); //Init_Plot(); //ST7735_SetCursor(0,0); ST7735_OutString("Lab 9"); ST7735_PlotClear(1000,4000); // range from 0 to 4095 ST7735_SetCursor(0,1); ST7735_OutString("N="); ST7735_SetCursor(0,2); ST7735_OutString("T="); //ST7735_DecOut2(2500); ST7735_OutString(" C"); EnableInterrupts(); while(1){ ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue); // 0 to 4095 if(refresh){ refresh = 0; samples++; ST7735_PlotPoint(ADCvalue); // Measured temperature if((samples&(N-1))==0){ // fs sampling, fs/N samples plotted per second ST7735_PlotNextErase(); // overwrites N points on same line } if((samples%fs)==0){ // fs sampling, 1 Hz display of numerical data //do conversion here, set it equal to temp. temp = get_temp(ADCvalue); ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue); // 0 to 4095 ST7735_SetCursor(3,2);ST7735_DecOut2(temp); // 0.01 C } } } }
void initboard() { CSL_init(); PLL_Init(); EMIF_Init(); TIMER_Init(); IRQ_globalDisable(); }
int main(void) { PLL_Init(); PortA_Init(); SysInit(); SysLoad(40000); while(1){} }
int main(void) { PLL_Init(); // 80 MHz GPIOPortA_Init(); while(1) { GPIO_PORTA_DATA_R^= 0x80; SysTick_Delay(90909); // Frequency = 880 Hz, Periodic Time = 2.27 ms } }
void mainTRANSMITTER(void) { asm sei // Disable interrupts PLL_Init(); ADC_Init(); sci1_Init(); DDRP |= 0x80; // PP7 output OC0_Init(); // Intializes timer as well asm cli // Enable interrupts for(;;) { /* Do Nothing */} }
// 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PLL_Init(); // 80 MHz //Sound_Init(); // initialize output and interrupts Button_Init(); EnableInterrupts(); while(1){ // interrupts every 500us //check iinputs poll interrupt for buttons? //display state //go to next state WaitForInterrupt(); } }
int main(void) { PLL_Init(); // 60 MHz GPIOPortA_Init(); while(1) { GPIO_PORTA_DATA_R^= 0x80; // Add your code here // End of your code } }
int main(void){ int useless =0; int a,b,c; DisableInterrupts(); PLL_Init(); // 50 MHz I think? LCD_Open(); ADC_InitSWTriggerSeq3(3); SysTick_Init(); SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; // activate port G useless = 1; useless =0; GPIO_PORTG_DIR_R |= 0x04; // make PG2 out (built-in LED) GPIO_PORTG_AFSEL_R &= ~0x04; // disable alt func on PG2 GPIO_PORTG_DEN_R |= 0x04; // enable digital I/O on PG2 PG2 = 0; // turn off LED UART_Init(); ADC_Init(); LCD_Clear(); EnableInterrupts(); while(1) { if((FIFO_Get() !=1) && getmail==0x2) { int i; int sendme; flag =0; //FIFO_Get(); LCD_GoTo(0); for(i = 0; i <5; i++) { FIFO_Get(); sendme = getmail; LCD_OutChar( sendme); } LCD_GoTo(20); LCD_OutChar(99); LCD_OutChar(109); FIFO_Get(); FIFO_Get(); // these two gets just take the blank space and the Stop 0x03 off the FIFO } } }
int main(void){ PLL_Init(); // configure for 50 MHz clock SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOD; SysTick_Init(); buttonInit(); musicInit(); DAC_Init(0xC000); setChangeTrackFunction(&changeTrack); while(1){ toggleLED(2); } }