Hi guys I am using AVR644p now, taking data from ADS1252(TI). I managed to get nice waveforms on oscilloscope, and now I would like to display it on the screen (Excel? Hyperterminal?)
I am a noob to RS232 so any advice is very much welcomed :)
I have connected my R1IN(pin13) and T1OUT(pin14) of ICL232 chip to RD(PIN2) and TD(PIN3) of RS232 cable, together with some 1uF polarised decoupling capacitors for the chip. On the other side, T1IN(pin11) and R1OUT(pin12) of the chip are connected to the TXD1 and RXD1 pins on AVR.
QUESTION ONE: how do I read out the data using RS232?
I am using another USART as USART_SPI mode to read data from my ADC. The code is as follow:
//Write to data register to initiate data transfer UDR0= 0; //Wait till 8 bits is received //Do nothing when Receive Complete Flag is ZERO ( means when it has not yet completely received data) while ((USART_CSR_A_Receive_Flag & UCSR0A) == 0) { } //Read the data //UDR0 is the 8- bit USART Data Register Data[2] = UDR0; UDR0 = 0; while ((USART_CSR_A_Receive_Flag & UCSR0A) == 0) { } Data[1] = UDR0; UDR0 = 0; while ((USART_CSR_A_Receive_Flag & UCSR0A) == 0) { } Data[0] = UDR0;
With this code I successfully see 3 consecutive bytes of data on oscilloscpoe.
A friend suggested that I need to take snapshot at every 8 sets of reading and stream that. The rough code he suggested is as follow:
unsigned char ToU[3]; //to usart //after reading from ADC Loop = (Loop + 1)&7; If (Loop == 0); //counted to 8 { ToU[0] = Data[0]; ToU[1] = Data[1]; ToU[2] = Data[2]; } int streamLoc = 0; //initialise index if streamLoc <3>; //take in 3 bytes of data USART_DataReg = ToU[streamLoc ++]; //increment
QUESTION TWO: how to I put the data from USART data register of this USART(for ADC) to the other USART(for RS232)?
QUESTION THREE: data from RS232 is in binary right? how do I read it on the computer?
QUESTION FOUR: do I need to convert the binary data to hex data first? what do I use for conversion?
QUESTION FIVE: how do I display that on lets say Excel?
Many thanks :)