From 368f4dcca9f8fdadfee527345b59f7a7ba6d6367 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 3 Dec 2016 21:16:13 -0500 Subject: Update tools encode a 2.5 MHz signal with the AVR. --- tools/avr_codegen/test.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/avr_codegen/test.c (limited to 'tools/avr_codegen/test.c') diff --git a/tools/avr_codegen/test.c b/tools/avr_codegen/test.c new file mode 100644 index 0000000..e962e09 --- /dev/null +++ b/tools/avr_codegen/test.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +void delay_ms(uint32_t time) { + uint32_t i; + for (i = 0; i < time; i++) { + _delay_ms(1); + } +} + +#define NOOP asm volatile("nop" ::) + + +static void setup_clock( void ) +{ + /*Examine Page 33*/ + + CLKPR = 0x80; /*Setup CLKPCE to be receptive*/ + CLKPR = 0x00; /*No scalar*/ + OSCCAL = 0x80; //B8 is bottom E8 is top. +} + +int main( ) +{ + cli(); + setup_clock(); + DDRB = _BV(4); + uint8_t marker; + + while(1) + { + marker = 0x05; + do{ + PORTB = _BV(4); + marker--; + PORTB = 0; + } while( marker ); + + _delay_us(1000000/60); + } + + return 0; +} -- cgit v1.2.3