diff options
author | Jonas Gunz <jonas.gunz@googlemail.com> | 2015-02-21 13:35:30 +0100 |
---|---|---|
committer | Jonas Gunz <jonas.gunz@googlemail.com> | 2015-02-21 13:35:30 +0100 |
commit | 820dd13d2170852441467fdf6d7f501fea7f0856 (patch) | |
tree | 5cf90e75e2363442554366b2dee06b4f4fe47e41 | |
parent | 02958346a0ff0a4e82f0fe23828d5955f3acbc67 (diff) | |
download | Intersil-ADC-Interface-on-AVR-ATmega8-master.tar.gz |
Thanks to Luca :D
-rw-r--r-- | Keithley179.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/Keithley179.c b/Keithley179.c index 4205c6f..79bc149 100644 --- a/Keithley179.c +++ b/Keithley179.c @@ -3,18 +3,12 @@ * Designed for the Keithley 179 True RMS Multimeter */ - -//#ifndef F_CPU #define F_CPU 4000000UL //4MHz -//#endif +#define USART_UART_BAUDRATE 9600 #include <avr/io.h> #include <avr/interrupt.h> -#define UART_BAUDRATE 960 - -#define baudrate ((F_CPU / UART_BAUDRATE * 16) - 1) - //Locations of ADC Outups (ICL71c03) #define b1 PC0 #define b2 PC1 @@ -109,8 +103,8 @@ int main(void) //INIT UART Interface UART_Init(); - //UART_Send("Hello World!"); - UART_Putc('A'); + + UART_Send("Hello World!"); //main loop while(1) { @@ -148,7 +142,7 @@ int main(void) UART_Send(out); //Handle UART - //UART_Handle(); //Not Used + UART_Handle(); //Reset Buffer for(int i = 0; i < 5;i++) @@ -165,12 +159,10 @@ void UART_Init() { if(UART_isInit == 0) { - //Calculate Value for Register - //uint16_t baudrate = (F_CPU / (UART_BAUDRATE * 16)) - 1; + uint16_t baudrate = (((F_CPU / (USART_UART_BAUDRATE * 16UL))) - 1); - //Set Baudrate - UBRRL = baudrate; UBRRH = (baudrate >> 8); + UBRRL = (baudrate & 0xFF); UCSRB |= (1<<RXEN) | (1<<TXEN); //Enable Reciever and Transmitter UCSRB |= (1<<RXCIE); //Enable Recieve Complete Interrupt @@ -188,6 +180,7 @@ void UART_Handle() { //Not Used //char in[16] is UART InputBuffer + // } }//UART_Handle @@ -197,8 +190,6 @@ void UART_Send(char *_cSend) { while(*_cSend) { - /*while (!(UCSRA & (1<<UDRE))); - UDR = *_cSend;*/ UART_Putc(*_cSend); _cSend++; } |