khatarat
Member level 1
hi
i want to send informations via serial port
this is my proram in winccr
i want to send 0 to 255. but this program send 0 to 14
and another problem is speed of sending .
this program with _delay_ms(1) send 800 chars in one second and without it nothing will send i thing speed should be more where is the problem?
#ifndef F_CPU
#define F_CPU 11059200
#endif
#define BAUD 115200
#include <avr/io.h>
#include <util/delay.h>
#include <util/setbaud.h>
void adc_init(void)
{
ADCSRA|=(1<<ADEN)|3;
}
void USART_Init()
{
UBRRH = UBRRH_VALUE;
UBRRL = UBRRL_VALUE;
#if USE_2X
UCSRA |= (1 << U2X);
#else
UCSRA &= ~(1 << U2X);
#endif
UCSRC =(1<<URSEL)|(0<<USBS)|(1<<UCSZ1)|(1<<UCSZ0);
UCSRB=(1<<RXEN)|(1<<TXEN);
}
void write(uint8_t Temp)
{
while(!(UCSRA&(1<<UDRE)));
UDR=Temp;
}
int main(void)
{
register uint8_t i;
i=0;
while(1)
{
write(i++);
_delay_ms(1);
}
return 0;
}
i want to send informations via serial port
this is my proram in winccr
i want to send 0 to 255. but this program send 0 to 14
and another problem is speed of sending .
this program with _delay_ms(1) send 800 chars in one second and without it nothing will send i thing speed should be more where is the problem?
#ifndef F_CPU
#define F_CPU 11059200
#endif
#define BAUD 115200
#include <avr/io.h>
#include <util/delay.h>
#include <util/setbaud.h>
void adc_init(void)
{
ADCSRA|=(1<<ADEN)|3;
}
void USART_Init()
{
UBRRH = UBRRH_VALUE;
UBRRL = UBRRL_VALUE;
#if USE_2X
UCSRA |= (1 << U2X);
#else
UCSRA &= ~(1 << U2X);
#endif
UCSRC =(1<<URSEL)|(0<<USBS)|(1<<UCSZ1)|(1<<UCSZ0);
UCSRB=(1<<RXEN)|(1<<TXEN);
}
void write(uint8_t Temp)
{
while(!(UCSRA&(1<<UDRE)));
UDR=Temp;
}
int main(void)
{
register uint8_t i;
i=0;
while(1)
{
write(i++);
_delay_ms(1);
}
return 0;
}