[ create a new paste ] login | about

Link: http://codepad.org/lly6GZIU    [ raw code | output | fork ]

krokodandi - C++, pasted on Nov 12:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>

#define F_CPU 7372800UL	
#define BAUDRATE 9600
#define BAUD_PRESCALLER (((F_CPU/(BAUDRATE * 16UL)))-1) //47
#define buffer_MAX 8

uint8_t index = 0;
char Massive_buff[] = {"ABCD"};
	
uint8_t init_uart()
{
	/*Init Usart */
	UCSR0A=(0<<RXC0) | (0<<TXC0) | (1<<UDRE0) | (0<<FE0) | (0<<DOR0) | (0<<UPE0) | (0<<U2X0) | (0<<MPCM0);             // 0010 0000
	UCSR0B=(0<<RXCIE0) | (0<<TXCIE0) | (0<<UDRIE0) | (1<<RXEN0) | (1<<TXEN0) | (0<<UCSZ02) | (0<<RXB80) | (0<<TXB80);  // 0001 1000
	UCSR0C=(0<<UMSEL0) | (0<<UPM01) | (0<<UPM00) | (0<<USBS0) | (1<<UCSZ01) | (1<<UCSZ00) | (0<<UCPOL0);               // 0000 0110
    UBRR0H = (uint8_t)(BAUD_PRESCALLER>>8);
    UBRR0L = (uint8_t)(BAUD_PRESCALLER);
	return 1;
}

ISR (USART0_UDRE_vect)	            
{
	index++;		            	
	if(index == buffer_MAX)  
	{
		UCSR0B &=~(1<<UDRIE0);	
	    DDRE |=(1<<4);
	    PORTE |=(1<<4);
	}
	else
	{
		UDR0 = Massive_buff[index];	
		
		DDRE |=(1<<3);
		PORTE ^=(1<<3);
		PORTE ^=(1<<3);
		PORTE ^=(1<<3);
		PORTE ^=(1<<3);
		PORTE ^=(1<<3);
		PORTE ^=(1<<3);
	}

}
void UART_send( uint8_t data){
	while(!(UCSR0A & (1<<UDRE0)));
	UDR0 = data;
	sei();
}

	
int main(void)
{
	init_uart();
    cli();
	UART_send (Massive_buff[index]);
	UCSR0B |=(1<<UDRIE0);
	while(1)
	{
		 asm("nop"); 
		 asm("nop"); 
		 asm("nop");
		 asm("nop");
		 asm("nop");
		
	}
	return 0;
}


Output:
1
2
3
4
Line 19: error: avr/io.h: No such file or directory
Line 26: error: avr/interrupt.h: No such file or directory
Line 10: error: 'uint8_t index' redeclared as different kind of symbol
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: