ismbn
Full Member level 3
- Joined
- Feb 11, 2012
- Messages
- 160
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,308
- Location
- Mumbai. india
- Activity points
- 2,444
Hi friend...
I am interfacing (in simulator) AD1674 which is a 12 bit ADC with ATmega32. I have made the connection as in the attachment. in the output of the ADC the data is changing, but when i am sending this through serial port, i am getting output as in the screenshot... it is giving output like this ascii 4080
" ≡≡≡≡...≡"
Here is the code
Is this kind of response is right???
please guide me...
Ismail...
I am interfacing (in simulator) AD1674 which is a 12 bit ADC with ATmega32. I have made the connection as in the attachment. in the output of the ADC the data is changing, but when i am sending this through serial port, i am getting output as in the screenshot... it is giving output like this ascii 4080
" ≡≡≡≡...≡"
Here is the code
Code:
#include <avr/io.h>
#include <util/delay.h>
#define RC_on sbit(PORTC,5);
#define RC_off clrbit(PORTC,5);
///////////////////////////////////// Variable declarection///////////////////////////
unsigned int x=0,y=0;
unsigned long z=0;
///////////////////////////////////// End Variable declarection///////////////////////////
unsigned char read( void )
{
/* Wait for incoming data */
while (!(UCSRA & (1<<RXC)));
/* Return the data */
return UDR;
}
void print( unsigned char data )
{
/* Wait for empty transmit buffer */
while (!(UCSRA & (1<<UDRE)));
/* Start transition */
UDR = data;
}
/* Transmit String Function */
void print_str( const char *str )
{
while (*str)
{
print(*str);
str++;
}
}
/////////////////////////////////// USART init //////////////////////////////////
void uart_init( unsigned int baud )
{
/* Set the baud rate */
UBRRH = (unsigned char) (baud>>8);
UBRRL = (unsigned char) baud;
/* Enable UART receiver and transmitter */
UCSRB = ( ( 1 << RXEN ) | ( 1 << TXEN ) );
/* Set frame format: 8 data 1stop */
UCSRC = (3<<UCSZ0);
}
///////////////////////////// End of USART init /////////////////////////////////
int main(void)
{
uart_init(103);
DDRA=00;
DDRB=0x00;
DDRC=0b11111111;
RC_on;
while(1)
{
_delay_ms(1);;
RC_off;
x=PINA;
y=PINB;
// print(x);
z=(y*255)+x; /// when i am using z=(y*255)+x; ≡≡ continuously
print(z); ///and when i am using z=(y*22)+x; III
RC_on;
}
}
Is this kind of response is right???
please guide me...
Ismail...