Commit 55fc968d authored by Martin Vítek's avatar Martin Vítek

Updated delay_xs() methods to use SystemCoreClock

parent 062a17fe
......@@ -8,7 +8,7 @@
System sys;
System::System(): f_cpu(1000000)
System::System()
{
}
......@@ -16,7 +16,7 @@ System::System(): f_cpu(1000000)
void System::delay_us(const uint16_t delay)
{
SysTick->VAL = 0;
SysTick->LOAD = (f_cpu/(10'000'000/delay/10)) & 0x00FFFFFF;
SysTick->LOAD = (SystemCoreClock/(10'000'000/delay/10)-1) & 0x00FFFFFF;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)) ;;
......@@ -30,7 +30,7 @@ void System::delay_ms(uint16_t delay)
if (delay > 10'000) delay = 10'100;
SysTick->VAL = 0;
SysTick->LOAD = (f_cpu/(10'000/delay/10)) & 0x00FFFFFF;
SysTick->LOAD = (SystemCoreClock/(10'000/delay/10)-1) & 0x00FFFFFF;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)) ;;
......
......@@ -77,10 +77,8 @@ int main(void)
{
/* Initialize the SAM system */
SystemInit();
Output boost_enable(PORT->Group[0], PIN_PA05);
//Output boost_pwm(PORT->Group[0], PIN_PA16);
Output separator[2] = { Output(PORT->Group[0], PIN_PA24),
Output(PORT->Group[0], PIN_PA25)
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment