]> git.mmlx.us Git - stellaris/led_blink.git/commitdiff
Send two chars per second through UART for testing
authorMatt Mullins <mmullins@mmlx.us>
Sun, 23 Dec 2012 17:33:21 +0000 (09:33 -0800)
committerMatt Mullins <mmullins@mmlx.us>
Sun, 23 Dec 2012 18:18:48 +0000 (10:18 -0800)
isr_table.c
main.c
main.h

index 367f4809138ee8e1883f4c6e6a1fdb9ec1e86fcd..e0d0f9b5c40c1b299daee2610370bf2cdbf4b352 100644 (file)
@@ -19,7 +19,7 @@ void (*reset_vectors[])() = {
        infinite_loop_isr,
        infinite_loop_isr,
        infinite_loop_isr,
-       infinite_loop_isr,
+       systick_isr,
        infinite_loop_isr,
        infinite_loop_isr,
        infinite_loop_isr,
diff --git a/main.c b/main.c
index 807e87944bf0123e726d1860590b1d6c4de7c91f..3588743ed2132ff48d71415532d9909d6092e2b5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -55,6 +55,14 @@ void main_isr() {
        // Go!
        UART0_CTL_R |= UART_CTL_UARTEN;
 
+       // Initialize our SysTick prescaler
+       systick_count = initial_systick_count;
+
+       // Initialize the SysTick module
+       NVIC_ST_RELOAD_R = 10000000; // produce 8Hz from 80MHz clock
+       NVIC_ST_CURRENT_R = 0;
+       NVIC_ST_CTRL_R |= 0x7;
+
        // infinite loop
        for (;;) { 
                asm("wfi");
@@ -76,3 +84,17 @@ void uart0_isr() {
        data = (data + 1) & 0xFF;
        UART0_DR_R = data;
 }
+
+__attribute__((isr))
+void systick_isr() {
+       // Divide the SysTick timer by (initial_systick_count+1) since the
+       // system clock is running pretty fast
+       if (systick_count) {
+               systick_count--;
+               return;
+       }
+       systick_count = initial_systick_count;
+
+       // Send a character out the UART for simple testing
+       UART0_DR_R = 'F';
+}
diff --git a/main.h b/main.h
index 63863fa9c4d70a3945f443244278b281fd72e1f2..0e92f19a802ca15d3181ecc9444ee06960d4c36f 100644 (file)
--- a/main.h
+++ b/main.h
@@ -3,5 +3,6 @@
 
 extern void main_isr();
 extern void uart0_isr();
+extern void systick_isr();
 
 #endif