From b523dc2ff55c46548695b525ccdeff7fa13687ba Mon Sep 17 00:00:00 2001 From: Edward Longman <el7g15@soton.ac.uk> Date: Tue, 9 Jul 2019 18:36:14 +0100 Subject: [PATCH] Correct TimerA0 interrupt, add logging of TA0C to UART, change LED indicator --- source/lib/hal_mcu/CMakeLists.txt | 8 ++++---- source/lib/hal_mcu/hal_fr5_timer.c | 15 ++++++++++----- source/lib/hal_mcu/hal_timer.h | 3 +++ source/lib/uart_drv/uart_drv.c | 2 -- source/test/min2.c | 9 ++++++--- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/source/lib/hal_mcu/CMakeLists.txt b/source/lib/hal_mcu/CMakeLists.txt index 5cf04a2..e450b26 100644 --- a/source/lib/hal_mcu/CMakeLists.txt +++ b/source/lib/hal_mcu/CMakeLists.txt @@ -5,9 +5,9 @@ include(${CMAKE_SOURCE_DIR}/../common.cmake) add_library( hal_mcu STATIC - #hal_f2_timerA0.c - #hal_f2_timerB0.c - #hal_f5_timerB0.c - #hal_fr5_timer.c + hal_f2_timerA0.c + hal_f2_timerB0.c + hal_f5_timerB0.c + hal_fr5_timer.c hal_mcu.c ) diff --git a/source/lib/hal_mcu/hal_fr5_timer.c b/source/lib/hal_mcu/hal_fr5_timer.c index 129003b..2bc3fbf 100644 --- a/source/lib/hal_mcu/hal_fr5_timer.c +++ b/source/lib/hal_mcu/hal_fr5_timer.c @@ -44,6 +44,12 @@ unsigned char volatile timer_event; unsigned long volatile time_counter = 0; +unsigned char get_reset_timer_wake_event(){ + unsigned char temp_event = timer_event; + timer_event = 0; + return temp_event; +} + /****************************************************************************** * @fn hal_timer_init * @@ -269,7 +275,7 @@ unsigned int hal_timer_wait(unsigned int time) { } /****************************************************************************** - * @fn TIMERA2_ISR + * @fn TIMERA0_ISR * * @brief Timer interrupt service routine * @@ -283,13 +289,12 @@ unsigned int hal_timer_wait(unsigned int time) { * @return void * */ -HAL_ISR_FUNC_DECLARATION(timer_a1_isr,TIMER_A1){ -//#pragma vector=TIMERB1_VECTOR -//__interrupt void TIMERB1_ISR(void) { +HAL_ISR_FUNC_DECLARATION(timer_a1_isr,TIMER_A0){ +//#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) ) { case TA0IV_NONE: break; // No interrupt case TA0IV_TACCR1: // Used to wake up radio from sleep diff --git a/source/lib/hal_mcu/hal_timer.h b/source/lib/hal_mcu/hal_timer.h index 9d26169..07332b4 100644 --- a/source/lib/hal_mcu/hal_timer.h +++ b/source/lib/hal_mcu/hal_timer.h @@ -37,6 +37,9 @@ /* prototypes using in creating a simple RF link */ +/* Get timer wake event type */ +unsigned char get_reset_timer_wake_event(); + /* Start packet timer using Timer using ACLK as reference */ void hal_timer_init(unsigned int master_count); diff --git a/source/lib/uart_drv/uart_drv.c b/source/lib/uart_drv/uart_drv.c index e2dbf73..fec181b 100644 --- a/source/lib/uart_drv/uart_drv.c +++ b/source/lib/uart_drv/uart_drv.c @@ -543,7 +543,6 @@ void hal_uart_start_tx(void) HAL_ISR_FUNC_DECLARATION(eUSCI_isr, EUSCI_A0) { char tmp_uart_data; - P1OUT ^= BIT0; switch(__even_in_range(UCA0IV,4)) { case UCIV__NONE: @@ -571,7 +570,6 @@ HAL_ISR_FUNC_DECLARATION(eUSCI_isr, EUSCI_A0) isr_state = TX_ISR_OFF; UCA0IE &= ~UCTXIE; // Disable USCI_A0 TX interrupt } - P1OUT ^= BIT0; break; // Vector 4 - TXIFG default: break; diff --git a/source/test/min2.c b/source/test/min2.c index 0376bb1..d3ce675 100644 --- a/source/test/min2.c +++ b/source/test/min2.c @@ -3,6 +3,7 @@ #include "lib/radio_drv/hal_types.h" #include "lib/hal_mcu/hal_mcu_fr5.h" #include "lib/uart_drv/uart_drv.h" +#include "lib/hal_mcu/hal_timer.h" /****************************************************************************** * LOCAL FUNCTIONS @@ -53,11 +54,12 @@ void main (void) /* Initialize the UART port */ hal_uart_init(); - // Enable the interupts on port 2 to catch the user button (TRXEB) - + // Setup the timer + hal_timer_init(0xFFFF); P1DIR |= BIT0 | BIT1; + P1OUT |= BIT0 | BIT1; __enable_interrupt(); /* Infinite loop with a 1 second timer */ while(1) @@ -67,6 +69,7 @@ void main (void) if(idle_counter!=main_time_counter){ idle_counter=main_time_counter; ee_printf("Cnt:%3i\n\r", idle_counter); + ee_printf("TA0CCR:0x%4X\n\r", TA0R); _delay_us(100000); } } @@ -90,6 +93,6 @@ HAL_ISR_FUNC_DECLARATION(wdt_isr,WDT) { main_time_counter++; /* global "0.5 second" counter used for printing time stamped packet sniffer data */ - P1OUT ^= BIT1; + P1OUT ^= BIT0; } -- GitLab