This cleans up a lot of code, since we no longer need to keep a software
counter. 32-bits is plenty of counting to turn 80MHz into 2Hz.
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
-// Since SysTick is only 24-bits, we'll need to divide it by 4 to produce a
-// 2Hz value from the 80MHz system clock.
-// Yes, I know I can just run the system clock slower, but this is more fun.
-static const int initial_systick_count = 3;
-static int systick_count;
-
__attribute__((isr))
void main_isr() {
// Power on the PLL, set to 16MHz XTAL
__attribute__((isr))
void main_isr() {
// Power on the PLL, set to 16MHz XTAL
// Set RGB pins to 1
*(GPIO_PORTF_DATA_BITS_R + 0xE) = 0xF;
// Set RGB pins to 1
*(GPIO_PORTF_DATA_BITS_R + 0xE) = 0xF;
- // Initialize our SysTick prescaler
- systick_count = initial_systick_count;
+ // Initialize the Timer 4 module
+ SYSCTL_RCGCTIMER_R |= (1 << 4);
+ TIMER4_CFG_R = 0x0; // 32-bit timer on shared 16/32-bit GPTM
+ TIMER4_TAMR_R = TIMER_TAMR_TAMR_PERIOD;
+ TIMER4_TAILR_R = 40000000; // produce 2Hz from 80MHz clock
- // Initialize the SysTick module
- NVIC_ST_RELOAD_R = 10000000; // produce 8Hz from 80MHz clock
- NVIC_ST_CURRENT_R = 0;
- NVIC_ST_CTRL_R |= 0x7;
+ // Enable interrupts for Timer 4A
+ TIMER4_IMR_R |= TIMER_IMR_TATOIM;
+ TIMER4_CTL_R |= TIMER_CTL_TAEN;
+ NVIC_EN2_R = (1 << (70 & 0x1F));
// infinite loop
for (;;) {
// infinite loop
for (;;) {
-__attribute__((isr))
-void systick_isr() {
- if (systick_count) {
- systick_count--;
- return;
- }
-
- systick_count = initial_systick_count;
+void __attribute__((isr))
+timer4a_isr() {
+ // Blink the LED [invert status twice per second]
*(GPIO_PORTF_DATA_BITS_R + 0xE) ^= 0xF;
*(GPIO_PORTF_DATA_BITS_R + 0xE) ^= 0xF;
+
+ // Clear interrupt status so this ISR doesn't infinite-loop
+ TIMER4_ICR_R = TIMER_ICR_TATOCINT;
#define __led_blink_H__
extern void main_isr();
#define __led_blink_H__
extern void main_isr();
-extern void systick_isr();
+extern void timer4a_isr();