// Insert compiler directives to set the optimization to zero
// We do not want the compiler to optimize out any code
#pragma GCC push_options
#pragma GCC optimize ("O0")
// Include the header file.
// In STM32 microcontroller programming, the header files provided by the
// manufacturer (STMicroelectronics) contain the necessary definitions,
// constants, and function prototypes specific to the microcontroller's peripherals
// and features.
#include "stm32c0xx.h"
// Include function declarations
void myDelay(unsigned int val);
int main(void)
{
// Enable GPIOD and configure PD0 as an output pin
RCC->IOPENR |= (1UL << 3);
GPIOD -> MODER &= ~(3UL);
GPIOD ->MODER |= (1UL);
while (1)
{
// Toggle the state of PD0
GPIOD ->ODR ^= (1UL);
// call a delay. Note that this delay is not an accurately timed delay
myDelay(200000);
}
}
// Add function definitions here
void myDelay(unsigned int val)
{
int i;
for (i = 0; i < val; i++);
}