Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] AD7490 Interfacing with Microcontroller

Status
Not open for further replies.

ashad

Full Member level 6
Joined
Mar 28, 2006
Messages
393
Helped
40
Reputation
80
Reaction score
28
Trophy points
1,308
Location
Trento, Italy
Activity points
3,296
Hi,

I am facing some problem in Reading Analogue values from AD7490. I always received FF from ADC. If any one interface this ADC with 8 bit Microcontroller then please share your experience.

Thanks
 

It could have may reasons. How does your circuit diagram looks like? Or are you using the evaluation board?

Enjoy your design work!
 

Upload your circuit diagram and Code ..
 

Thanks for reply... The circuit is according to the data sheet ... I was confused due to arrangement of 12bit command word.
According to the datasheet 12bit command word with 12th bit MSB (write) and LSB is Coding bit. However We have 16 bit integer so I m confused that either I need to send 0x8330 command byte or 0x08333 command byte. Following is the coding for ur reference.



Code:
	unsigned int	adnum=1;
	unsigned char	dnum=0;
	union ad_cmd
	{
		unsigned int	adint; 		// adint = adchar[1]+adchar[0]
		unsigned char	adchar[2];		
	};
	union ad_cmd adcmd1;
	unsigned int	maskint= 0xC3F0;	//0b1100 0011 1111
								//    --c-- 
	adcmd1.adint = 0x8330;			//0b1000 0011 0111 0000
	
	adnum=0;
	dnum=0;
	do
		{

		adcmd1.adint &= maskint;
		adcmd1.adint |= (adnum<<10);	//Shifted for 10time

		SPDR = 	adcmd1.adchar[1];
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		SPDR = 	adcmd1.adchar[0]; 
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete


		_delay_ms(10);
	
		SPDR = 	0x03;
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		ad7490_data[dnum]= SPDR;
	
		dnum++;
		SPDR = 	0x30; 
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		ad7490_data[dnum]= SPDR;

		adnum++;
		dnum++;
		}while (adnum < 16);
 

Please post the circuit and mention which Compiler you are using. Its better if you Zip and post also the project files.
 

I am using AVR studio 4 and Atmega168 controller.

ad7490.png
 

The circuit is according to the data sheet
I don't see that you control the CS (SS) line at all which is essential for SPI operation.

You also didn't mention that you are dealing with ATmega and don't show the SPCR settings. Please come back with complete information.

Shifting out control register content left aligned in 16-Bit SPI data is basically correct.

- - - Updated - - -

One point clarified at least.
 
  • Like
Reactions: ashad

    ashad

    Points: 2
    Helpful Answer Positive Rating
I asked you for the Circuit diagram and not the pinout of your ADC chip.
 

accept my apology

Code:
void	iniSPI(void)
{
	SPSR	=0x00;
	SPCR	=0b01011001;	//0x59
			
}//void	iniSPI(void)
//------------------------------Main Program ---------------

	while(1)
	{
	   	while(!(UCSR0A & (1<<RXC0)));
		
		if(UDR0 == 's')
			{
	//		while(UDR0 != 'x')
	//			{
				PORTB &= ~(1 << SSADC0); 
				_delay_ms(100);
				adcid01();
				ad7490_int();
	//			read_sensor();

//				adcid02();
//				PORTB &= ~(1 << SSADC1); 
//				_delay_ms(10);
//				ad7490_int();
//				read_sensor();
	//			}
			}


	}//	while(1)

//-----------------------ADC initialization Routine
void	ad7490_int(void)
{
	unsigned int	adnum=1;
	unsigned char	dnum=0;
	union ad_cmd
	{
		unsigned int	adint; 		// adint = adchar[1]+adchar[0]
		unsigned char	adchar[2];		
	};
	union ad_cmd adcmd1;

	unsigned int	maskint= 0xC3F0;	//0b1100 0011 1111
//	unsigned int	maskint= 0x0C3F;	//0b0000 1100 0011 
//	adcmd1.adint = 0x0833;				//0b0000 1000 0011 0111
										//    --c-- 
	adcmd1.adint = 0x8330;				//0b1000 0011 0111 0000
	
//	SPDR = 	adcmd1.adchar[1];
//	while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
	
//	SPDR = 	adcmd1.adchar[0]; 
//	while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete

	
	adnum=0;
	dnum=0;
	do
		{

		adcmd1.adint &= maskint;
		adcmd1.adint |= (adnum<<10);	//Shifted for 10time

		SPDR = 	adcmd1.adchar[1];
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		SPDR = 	adcmd1.adchar[0]; 
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete


		_delay_ms(10);

		serial_write(adnum);
	
		SPDR = 	0x03;
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		ad7490_data[dnum]= SPDR;
		serial_write(ad7490_data[dnum]);
	
		dnum++;
		SPDR = 	0x30; 
		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
		ad7490_data[dnum]= SPDR;
		serial_write(ad7490_data[dnum]);

		adnum++;
		dnum++;
		}while (adnum < 16);

//		adcmd1.adint &= maskint;

//		SPDR = 	adcmd1.adchar[1];
//		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
//		ad7490_data[dnum]= SPDR;

//		dnum++;
//		SPDR = 	adcmd1.adchar[0]; 
//		while(!(SPSR & (1<<SPIF)));  // wait until transmission is complete
//		ad7490_data[dnum]= SPDR;

//		PORTB |= (1 << SSADC0);
//		PORTB |= (1 << SSADC1);

}//void	ad7490_int(void);

- - - Updated - - -

I recevied already designed PCB in which AD7490 connected to Atmega168 controller

PB2 is connected with First AD7490 CS pin
PB1 is connected with Second AD7490 CS pin

MOSI is connected with DIN of AD7490
MISO is connected with DOUT of AD7490
SCLK is connected with SCLK pin of AD7490
 
  • Like
Reactions: urdxg

    urdxg

    Points: 2
    Helpful Answer Positive Rating
According to the datasheet AD7490 requires CS as framing signal for every 16 bit read or write transaction.

That's not implemented in your code.
 
  • Like
Reactions: ashad

    ashad

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top