From 2aa5fe3e1b1de7a8d6ed0d6c80a1ecab92ac1c88 Mon Sep 17 00:00:00 2001
From: Edward Longman <el7g15@soton.ac.uk>
Date: Tue, 9 Jul 2019 19:11:25 +0100
Subject: [PATCH] Force the interrupt type for unkn. reason and setup main to
 trigger the timer for the first time, only gets to the first time and then
 sticks in LPM0,

---
 source/lib/hal_mcu/hal_fr5_timer.c |  6 ++++--
 source/test/min2.c                 | 19 ++++++++++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/source/lib/hal_mcu/hal_fr5_timer.c b/source/lib/hal_mcu/hal_fr5_timer.c
index 2bc3fbf..2081775 100644
--- a/source/lib/hal_mcu/hal_fr5_timer.c
+++ b/source/lib/hal_mcu/hal_fr5_timer.c
@@ -289,13 +289,15 @@ unsigned int hal_timer_wait(unsigned int time) {
  * @return      void
  *
  */
-HAL_ISR_FUNC_DECLARATION(timer_a1_isr,TIMER_A0){
+//HAL_ISR_FUNC_DECLARATION(timer_a1_isr,TIMER0_A0){
+void __attribute__((interrupt(TIMER0_A0_VECTOR),used)) timer_a1_isr(void){
 //#pragma vector=TIMERA0_VECTOR
 //__interrupt void TIMERA0_ISR(void) {
 
 	/* Any access, read or write, of the TBIV register automatically
 	 * resets the highest "pending" interrupt flag. */
-	switch( __even_in_range(TAIV,14) ) {
+  P1OUT ^= BIT1;
+	switch( __even_in_range(TA0IV,14) ) {
     case  TA0IV_NONE: break;               // No interrupt
     case  TA0IV_TACCR1:                    // Used to wake up radio from sleep
       timer_event = TA0IV_TACCR1;
diff --git a/source/test/min2.c b/source/test/min2.c
index d3ce675..9f60a9e 100644
--- a/source/test/min2.c
+++ b/source/test/min2.c
@@ -70,7 +70,24 @@ void main (void)
 			idle_counter=main_time_counter;
 			ee_printf("Cnt:%3i\n\r", idle_counter);
 			ee_printf("TA0CCR:0x%4X\n\r", TA0R);
-			_delay_us(100000);
+			//Allow the UART to finish
+			_delay_us(1736);
+			//Toggle LED, wait Toggle again
+			P1OUT ^= BIT1;
+			TA0R = 1;
+		  TA0CCTL1 = CCIE;                       // interrupt enabled
+		  _BIS_SR(LPM0_bits + GIE);             // Enter LPM0
+
+			// while(get_reset_timer_wake_event()==0){
+			// 	NOP();
+		  // 	//_BIS_SR(LPM0_bits + GIE);             // Enter LPM0
+			// }
+			//We've exited by some means this LPM0
+			P1OUT ^= BIT0;
+
+		}
+		if(idle_counter>10){
+			//Use LPM0 For sleep
 		}
 	}
 }
-- 
GitLab