Changeset - 5a775958ef65
[Not reviewed]
default
0 2 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-20 12:13:06
ethanzonca@CL-SEC241-08.cedarville.edu
Program timer is operational
2 files changed with 7 insertions and 4 deletions:
0 comments (0 inline, 0 general)
master/master/lib/looptime.c
Show inline comments
 
@@ -2,15 +2,17 @@
 
 * looptime.c
 
 *
 
 * Created: 11/19/2012 8:56:42 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#include "../config.h"
 
#include <avr/io.h>
 
#include <avr/interrupt.h>
 
volatile uint32_t millis = 0; // Milliseconds since initialization
 
#include <avr/delay.h>
 
extern volatile uint32_t millis = 0; // Milliseconds since initialization
 

	
 

	
 

	
 
void time_setup() {
 
	DDRA = 0xff;
 
	
 
@@ -22,13 +24,12 @@ void time_setup() {
 
	TIFR0 |= ( 1 << TOV0 ); // clear pending interrupts
 
	TIMSK0 |= (1 << TOIE0); // enable overflow interrupt
 
}
 

	
 

	
 
ISR(TIMER0_OVF_vect) {
 
	PORTA = 0xff;
 
	millis++;
 
	millis = millis + 1;
 
}
 

	
 
uint32_t time_millis() {
 
	return millis; // meh accuracy, but that's OK
 
}
master/master/master.c
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "lib/aprs.h"
 
#include "lib/afsk.h"
 
#include "lib/led.h"
 
#include "lib/logger.h"
 
#include "lib/watchdog.h"
 
#include "lib/sd/sd_raw_config.h"
 
#include "lib/looptime.h"
 

	
 
void micro_setup() {
 

	
 
}
 

	
 
int main(void)
 
@@ -50,13 +51,14 @@ int main(void)
 
		
 
	char logbuf[32];
 
	
 
	while(1)
 
    {
 
		led_on(STAT);
 
		sprintf(logbuf, "%d,%d,%d,%d,%d,%d\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2);
 
		//sprintf(logbuf, "%d,%d,%d,%d,%d,%d\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2);
 
		sprintf(logbuf, "%d,\n", time_millis());
 
		logger_log(logbuf);
 
		led_off(STAT);
 
		
 
		// Wait for transmission to complete before starting another.
 
		// Hopefully this will never delay because it should issue on a timed schedule. Software timers!
 
		while(afsk_busy());
0 comments (0 inline, 0 general)