/*This code below are optimiser code that allow me to run the myDelay
function without error and the optimization is set to 0. Without those codes,
myDelay function wouldn't run because this function could have been considered
as useless function because it does not perform anything.
*/
#pragma GCC push_options
#pragma GCC optimize ("O0")
//As in all program, you need to include files so that the codes use here
//maybe recognize by the software and microcontroller. Ex. printf().
#include "stm32c0xx.h"
//As we have added two files for the header and function codes
//we have to include the header file name here so that the function
//can be called.
#include "mySysTick.h"
int main(void)
{
//first you Enable pins.
RCC -> IOPENR |= 13UL; //ENABLE GPIO A, C, and D
RCC -> IOPENR |= (1UL << 5); //ENABLE GPIO F
//Then you set your pins
GPIOA -> MODER &=~ (3UL << 26);
GPIOA -> MODER |= (1UL << 26); //ENABLING PIN PA13 AS OUTPUT
GPIOC -> MODER &=~ (3UL << 26);
GPIOC -> MODER |= (1UL << 26); //ENABLING PIN PC13 AS OUTPUT
GPIOD -> MODER &=~ (3UL);
GPIOD -> MODER |= 1UL; //ENABLING PIN PD0 AS OUTPUT
GPIOD -> MODER &=~ (3UL << 4);
GPIOD -> MODER |= (1UL << 4); //ENABLING PIN PD2 AS OUTPUT
GPIOF -> MODER &=~ 3UL;
GPIOF -> MODER |= 1UL; //ENABLING PIN PF0 AS OUTPUT
GPIOF -> MODER &=~ (3UL << 1);
GPIOF -> MODER |= (1UL << 1); //ENABLING PIN PF0 AS OUTPUT
//while loop execution
while(1)
{
// ^= implement the XOR gate rule when for each iteration the position
//of the bit toggle to 1 or 0.
GPIOF -> ODR ^= (1UL << 1);
//Accurate timer delay
myDelay(1000);
}
}
//***********end main()***********