From be5d5ddf1e054059b39ad143b6e071d7d2552f65 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sat, 26 Nov 2016 22:44:56 +0100 Subject: [PATCH] Fixed timeout timers --- software/Arduino/ardusss7.cpp | 9 +++++++-- software/Arduino/main.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/software/Arduino/ardusss7.cpp b/software/Arduino/ardusss7.cpp index a1967be..2fe4b56 100644 --- a/software/Arduino/ardusss7.cpp +++ b/software/Arduino/ardusss7.cpp @@ -61,7 +61,6 @@ uint8_t uart_get_byte() { } ISR(USART2_RX_vect) { - //PORTB ^= (1 << PB7); sss7_process_rx(); } @@ -71,9 +70,15 @@ ISR(USART2_TX_vect) { void SSS7Wrapper::setupTimer() { + TCCR4B = 0; TCNT4 = 65535 - 16000; //Preload for 16000 ticks to overflow - TIMSK4 |= (1 << TOIE0); + + // Take the Timer by force ... + TCCR4A = 0; TCCR4B = (1 << CS40); // Prescaler 1 + TCCR4C = 0; + + TIMSK4 = (1 << TOIE4); } ISR(TIMER4_OVF_vect) { diff --git a/software/Arduino/main.cpp b/software/Arduino/main.cpp index 29b636a..c2864c8 100644 --- a/software/Arduino/main.cpp +++ b/software/Arduino/main.cpp @@ -28,7 +28,6 @@ void loop() { while(1) { - Serial.println("Waiting to send"); while(!SSS7.canSend()); Serial.println("Sending ..."); @@ -39,6 +38,14 @@ void loop() { Serial.println("Send failed"); } + + if(SSS7.hasReceived()) { + uint8_t msg1[SSS7_PAYLOAD_SIZE]; + SSS7.getReceived(msg1); + Serial.print("Got data:"); + Serial.println((char*)msg1); + } + _delay_ms(1000); }