// Enable HSE (High-Speed External) oscillator and wait for it to stabilize MDR_RST_CLK->HS_CONTROL |= RST_CLK_HS_CONTROL_HSE_ON; while ((MDR_RST_CLK->CLOCK_STATUS & RST_CLK_CLOCK_STATUS_HSE_RDY) == 0); // Set the source of the PLL (Phase-Locked Loop) to HSE MDR_RST_CLK->PLL_CONTROL = (MDR_RST_CLK->PLL_CONTROL & ~RST_CLK_PLL_CONTROL_PLL_CPU_SEL_Msk) | RST_CLK_PLL_CONTROL_PLL_CPU_SEL_HSE; // Set the multiplier and divider for the PLL to obtain the desired frequency MDR_RST_CLK->PLL_CONTROL = (MDR_RST_CLK->PLL_CONTROL & ~(RST_CLK_PLL_CONTROL_PLL_CPU_MUL_Msk | RST_CLK_PLL_CONTROL_PLL_CPU_DIV_Msk)) | ((13 << RST_CLK_PLL_CONTROL_PLL_CPU_MUL_Pos) | (1 << RST_CLK_PLL_CONTROL_PLL_CPU_DIV_Pos)); // Enable the PLL and wait for it to stabilize MDR_RST_CLK->PLL_CONTROL |= RST_CLK_PLL_CONTROL_PLL_CPU_ON; while ((MDR_RST_CLK->CLOCK_STATUS & RST_CLK_CLOCK_STATUS_PLL_CPU_RDY) == 0); // Set the frequency of the CPU clock to the frequency of the PLL MDR_RST_CLK->CPU_CLOCK = (MDR_RST_CLK->CPU_CLOCK & ~RST_CLK_CPU_CLOCK_CPU_C1_SEL_Msk) | RST_CLK_CPU_CLOCK_CPU_C1_SEL_PLLCPUo; #include #include "MDR32Fx.h" #include "MDR32F9Qx_port.h" int main(void) { // Initialize the LED panel on I/O port B PortInit(LED_PORT_B, LED_PIN_MASK_B, PORT_OE_OUT); // Define the variables uint8_t var1 = 15; uint8_t var2 = 0xAA; // Wait for the SB4 button to be pressed while ((PORT_ReadInputData(LED_PORT_C) & SB4_PIN) != 0); // Perform the AND operation and display the result on the LED panel PortSet(LED_PORT_B, var1 & var2); // Wait for the SB4 button to be released while ((PORT_ReadInputData(LED_PORT_C) & SB4_PIN) == 0); return 0; } #include "MDR32Fx.h" #include "MDR32F9Qx_port.h" #define LED_MASK_A (0xFF << 8) int main(void) { // Initialize the LEDs on I/O port A PortInit(LED_PORT_A, LED_MASK_A, PORT_OE_OUT); // Turn on the center LED PORT_SetBits(LED_PORT_A, LED_MASK_A >> 1); // Wait for a moment for (volatile int i = 0; i < 1000000; i++); // Turn on the adjacent LEDs PORT_SetBits(LED_PORT_A, (LED_MASK_A >> 2) | (LED_MASK_A << 2)); // Wait for a moment for (volatile int i = 0; i < 1000000; i++); //