Hi
I have been working with the LPC1768 and I found some code I don't fully
understand
core_cm3.c
static inline uint32_t SysTick_Config(uint32_t n_ticks)
{
....
systick_set_reload(n_ticks);
systick_set_clocksource(true);
systick_interrupt_enable();
systick_counter_enable();
return 0;
}
I see the implementation looks like this:
void systick_set_clocksource(uint8_t clocksource)
{
STK_CSR = (STK_CSR & ~STK_CSR_CLKSOURCE) |
(clocksource & STK_CSR_CLKSOURCE);
}
STK_CSR_CLKSOURCE is ultimately defined as (1 << 2). I don't understand how
'(1 << 2) & true' is meaningful.
I found this because passing true to systick_set_reload() caused Systick to
behave incorrectly. I think this is probably better (systick works)
void systick_set_clocksource(uint8_t clocksource)
{
STK_CSR = (STK_CSR & ~STK_CSR_CLKSOURCE) |
(clocksource ? STK_CSR_CLKSOURCE : 0);
}
Did I miss something?
--
www.nicecupoftea.com
www.biscuit.com <http://www.mincepie.com/>
------------------------------------------------------------------------------
_______________________________________________
libopencm3-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libopencm3-devel