[attachment=0]SerialResultFrom Baby Orangutan328p.Hello everyone ,
I’m working on a project that communicate use serial and I got the code working in arduino IDE. But I’m having trouble transferring some lines of code from my code that written in Arduino 1.0.5 to Avr studio 6. So I use my baby orangutan 328 and programming it with pololu avr usb programmer.
In Avr studio 6 I can only read out Ascii code in serial, but some reason i can’t get any addition to work in the program.
void USART_Transmit( unsigned int data )
/* Wait for empty transmit buffer */
while ( !( UCSRnA & (1<<UDREn))) )
/* Copy 9th bit to TXB8 */
UCSRnB &= ~(1<<TXB8);
if ( data & 0x0100 )
UCSRnB |= (1<<TXB8);
/* Put data into buffer, sends the data */
UDRn = data;
unsigned int USART_Receive( void )
unsigned char status, resh, resl;
/* Wait for data to be received */
while ( !(UCSRnA & (1<<RXCn)) )
/* Get status and 9th bit, then data */
/* from buffer */
status = UCSRnA;
resh = UCSRnB;
resl = UDRn;
/* If error, return -1 */
if ( status & (1<<FEn)|(1<<DORn)|(1<<UPEn) )
/* Filter the 9th bit, then return */
resh = (resh >> 1) & 0x01;
return ((resh << 8) | resl);
/*in Avr Studio*/
received data1 97 data2 97
Total’s output is 97.
can anyone help me fix this?
Total’s is suppose to be 194 not 97…
any help would be appreciated.