aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-04 15:38:23 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-04 15:38:23 +0200
commit9753f9ffc43622bd02d86106f30361dd85583f71 (patch)
tree720864c565012f5782d9077803b956a3c28389ec
parent4c9a0e8ee2e261ea56d79aa1726b54492f6d67b2 (diff)
downloadrenard_hb9hi-9753f9ffc43622bd02d86106f30361dd85583f71.tar.gz
renard_hb9hi-9753f9ffc43622bd02d86106f30361dd85583f71.tar.bz2
renard_hb9hi-9753f9ffc43622bd02d86106f30361dd85583f71.zip
Remove PTT_LOGIC_LOW and fix timer
-rw-r--r--src/testapp1/main.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/src/testapp1/main.c b/src/testapp1/main.c
index d7e571d..c5d3102 100644
--- a/src/testapp1/main.c
+++ b/src/testapp1/main.c
@@ -12,7 +12,7 @@
#define PORTB_LED (1 << 4)
/* Specify ID here */
-static const uint8_t renard_id = 1;
+static const uint8_t renard_id = 0;
static const uint8_t num_renards_cycle = 4;
// colon (:) represents ERROR
@@ -24,13 +24,11 @@ volatile uint8_t reset_time;
volatile uint8_t systick; /* Timer (100Hz increment) */
volatile uint32_t seconds;
-/*---------------------------------------------------------*/
-/* 100Hz timer interrupt generated by OC2 */
-/*---------------------------------------------------------*/
-ISR(TIMER1_COMPA_vect)
+/* 200Hz timer interrupt */
+ISR(TIM0_COMPA_vect)
{
systick++;
- if (systick == 10) {
+ if (systick == 20) {
systick = 0;
seconds += 1;
}
@@ -43,11 +41,11 @@ ISR(TIMER1_COMPA_vect)
static int inittimer(void)
{
- /* Start 100Hz system timer (TC2.OC) */
- TCCR0B |= (1 << WGM02); // Configure timer for CTC mode
- TIMSK |= (1 << OCIE1A); // enable compare match A interrupt
- OCR1A = (uint8_t)(F_CPU / 64 / 1000 / 100 - 1); // Set CTC compare value to 10ms
- TCCR0B |= ((1 << CS10) | (1 << CS11)); // Start timer at Fcpu/64
+ /* Start 200Hz system timer */
+ TCCR0B |= (1 << WGM01); // Configure timer for CTC mode
+ TIMSK |= (1 << OCIE0A); // enable compare match A interrupt
+ OCR0A = (uint8_t)(F_CPU / 64 / 50); // Set CTC compare value to 50ms
+ TCCR0B |= ((1 << CS00) | (1 << CS01)); // Start timer at Fcpu/64
// Enable interrupts
sei();
@@ -55,27 +53,6 @@ static int inittimer(void)
return 0;
}
-#define PTT_LOGIC_LOW 0
-
-#if PTT_LOGIC_LOW
-void dah(void)
-{
- PORTB = PORTB_LED; // LED is non-inverted logic
- delay_ms(3*DIT_DURATION);
-
- PORTB = PORTB_PTT; // PTT is inverted logic
- delay_ms(DIT_DURATION);
-}
-
-void dit(void)
-{
- PORTB = PORTB_LED; // LED is non-inverted logic
- delay_ms(DIT_DURATION);
-
- PORTB = PORTB_PTT; // PTT is inverted logic
- delay_ms(DIT_DURATION);
-}
-#else
void dah(void)
{
PORTB = PORTB_PTT | PORTB_LED;
@@ -93,7 +70,6 @@ void dit(void)
PORTB = 0;
delay_ms(DIT_DURATION);
}
-#endif
int main(void)
{
@@ -102,10 +78,6 @@ int main(void)
reset_time = 0;
/* Enable PTT output on PB0 */
-#if PTT_LOGIC_LOW
- PORTB = PORTB_PTT;
-#endif
- /* LED is never inverted */
DDRB = PORTB_PTT | PORTB_LED;
/* initialise timer interrupt */