Int main - ASSIGNMENT PDF

Title Int main - ASSIGNMENT
Author samreen arif
Course Applied Thermodynamics
Institution University of Engineering and Technology Lahore
Pages 9
File Size 93.4 KB
File Type PDF
Total Downloads 91
Total Views 139

Summary

ASSIGNMENT...


Description

int main (void) { */ HAL_Init (); / * initilazie systick timer * /

SystemClock_Config (); / * start LED * /

BSP_LED_Init (LED1); BSP_LED_Init (LED2); BSP_LED_Init (LED3); BSP_LED_Init (LED4);

BSP_LED_On (LED2); BSP_LED_On (LED3); BSP_LED_On (LED4); 4. To adjust the SysTick timeline, use the following formula: if (SysTick_Config (SystemCoreClock / 2000)) { / * Shooting error * / while (1) {} }

while (1) { / * Switch LED2 and LED4 * /

BSP_LED_Toggle (LED1);

/ * Enter a delay of 50 ms * / HAL_Delay (50); / * Switch LED1 and LED3 * / BSP_LED_Toggle (LED2); BSP_LED_Toggle (LED3); BSP_LED_Toggle (LED4); / * Enter 200 ms delay * / HAL_Delay (200); } }

Question2 #include #define New_Line 0xA void UARTWrite(char data); int main(void) { char msg[] = { ‘E’,’l’,’e’,’c’,’t’,’r’,’o’,’n’,’i’,’c’,’s’,’ ‘,’H’,’u’,’b’,’\0′ }; int c=0; // counter

/* Configuring PLL for generation of 60 MHz CCLK and PCLK */

PLL0CON = 0x01; PLL0CFG = 0x23; PLL0FEED = 0xaa; PLL0FEED = 0x55; while(!(PLL0STAT & 0x00000400)); PLL0CON = 0x03; PLL0FEED = 0xaa; PLL0FEED = 0x55; VPBDIV = 0x01;

/*Configure and Initialize UART */

PINSEL0 = 0x5;

/*Select TxD for P0.0 and RxD for P0.1*/

U0LCR = 0x43; /*8 data bits, no Parity, 1 Stop bit | DLAB is set to 1*/ U0DLL = 0x6e; /* DLL set to 110*/ U0DLM = 0x01; /* DLM set to 1*/ U0FDR = 0xf1; /* MULVAL bits – 7:4) is set to 15 and DIVADDVAL (bits – 3:0) is set to 1*/ U0LCR &= 0x0f; // Set DLAB=0 to lock MULVAL and DIVADDVAL while (1) {

while( msg[c]!=’\0′ ) { UARTWrite(msg[c]); c++; } UARTWrite(New_Line); c=0; } } void UARTWrite(char data) { while ( !(U0LSR & 0x02 ) ); // wait till the THR is empty U0THR = data; }

quesTion3 ** * @brief Main main for WWDT example * @ return Nothing * / int main (void) { Uint32_t wdtFreq;

/ * Setting Board * /

Board_Init ();

/ * Launch WWDT (and enable WWDT clock) * / Chip_WWDT_Init (LPC_WWDT);

/ * Before starting the watchdog driver, watch the watchdog must be enabled. This example uses a viewing osdillator set at a clock speed of 50KHz (1Mhz / 20). * / Chip_SYSCTL_PowerUp (SYSCTL_POWERDOWN_WDTOSC_PD); Chip_Clock_SetWDTOSC (WDTLFO_OSC_1_05, 20);

/ * WDT divides the input frequency by 4 * / wdtFreq = Chip_Clock_GetWDTOSCRate () / 4;

/ * LPC1102 / 4, LPC11XXLV, and LPC11CXX devices select watchdog Clock source from SYSCLK block, while LPC11AXX, LPC11EXX, and LPC11UXX devices select the clock as part of the watch block. * / / * Select WDT clock source watch oscillator * / # if specified (CHIP_LPC110X) || defined (CHIP_LPC11XXLV) || defined (CHIP_LPC11CXX) || defined (CHIP_LPC11EXX) Chip_Clock_SetWDTClockSource (SYSCTL_WDTCLKSRC_WDTOSC, 1); #but Chip_WWDT_SelClockSource (LPC_WWDT, WWDT_CLKSRC_WATCHDOG_WDOSC); #final

Board_LED_Set (0, false);

/ * Set watch dog feed time to about 2s Set 512 tick watch dog warning time after feed time Set the view window time to 3 * Chip_WWDT_SetTimeOut (LPC_WWDT, wdtFreq * 2); # if specified (CHIP_LPC11CXX)

Chip_WWDT_SetWarning (LPC_WWDT, 512); Chip_WWDT_SetWindow (LPC_WWDT, wdtFreq * 3); #final

# if specified (CHIP_LPC11CXX) / * Configure WWDT reset during closing * / Chip_WWDT_SetOption (LPC_WWDT, WWDT_WDMOD_WDRESET); #final

/ * Setup Systick to feed viewer timer. This needs to be done * at a faster rate than WDT warning. * / SysTick_Config (Chip_Clock_GetSystemClockRate () / 50);

/ * Clear dog watch alert and closing time * / # if specified (CHIP_LPC11CXX) Chip_WWDT_ClearStatusFlag (LPC_WWDT, WWDT_WDMOD_WDTOF | WWDT_WDMOD_WDINT); #but Chip_WWDT_ClearStatusFlag (LPC_WWDT, WWDT_WDMOD_WDTOF); #final

/ * Clear and enable watchdog to interrupt * / NVIC_ClearPendingIRQ (WDT_IRQn); NVIC_Enables IRQ (WDT_IRQn);

/ * Start watchdog * / Chip_WWDT_Start (LPC_WWDT);

/ * Eat while waiting * / while (1) { __WFI (); } }

Question#4 int main (void) { static char ledsta; / *************************************** / SystemClock_HSI (9); cycleCounterInit (); // Init cycle calculator SysTick_Config (SystemCoreClock / 1000); , 1ms UART1_init (SysClock, uart1baudSet); NVIC_INIT (); STMFLASH_Unlock (); UploadParamsFromEEPROM (); LedInit (); Adc_Init (); KeyInit (); NRF24L01_INIT (); SetTX_Mode (); Clibra control (); #ifdef UART_DEBUG TIM3_Init (SysClock, 2000); #final TIM4_Init (SysClock, TIME4_Preiod); /: (TIME4_Preiod)

ILedSet (led2,1); LedSet (led3,1);

UploadRCdata (); // RockerUnlockcrazepony (); Lockflag = 0;

ILedSet (led2,0); LedSet (led3,0);

while (1) { // 10Hz loop if (flag10Hz == 1) // 10Hz { flag10Hz = 0; / * status paid * / ledsta =! ledsta; LedSet (signed, ledsta); / * crazepony Lock * / KeyLockcrazepony (); / * IMUcalibrate * / IMUcalibrate (); / * remote measurement * / Remotecalibrate (); }

// 50Hz loop if (flag50Hz == 1) { UploadRCdata (); flag50Hz = 0;

}

// 80Hz 12.5ms if (flag80Hz) { flag80Hz = 0; CommUAVU upload (MSP_SET_4CON); }

} }...


Similar Free PDFs