CS5460 energy measurement

Status
Not open for further replies.

kirtan

Junior Member level 2
Joined
Mar 11, 2011
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Visit site
Activity points
1,515
I working with CS5460 interfaced over SPI with Atmega32 (it has inbuilt SPI peripheral support)

part of the main code is given below. Problem is that after i start conversion DRDY bit is not set and the program waits in checking it forever..

I have gone through couple of thread and codes but can't figure out the problem

Kindly help me

int main()
{
delay_100ms(1);
init_uart();
init_spi();

CS5460_reset(); //this send 3 sync1 and 1 sync0 command and a command for soft reset
delay_100ms(1);


CS5460_init_configure(); //this load default values particularly clear status and mask register
delay_100ms(1);

CS5460_start_conversion();//do continuous conversion mode
delay_100ms(1);
send_string_uart("started convertion \r\n"); //just for knowing the status

while(!(CS5460_DRDY_ready())); //check if DRDY is set

send_string_uart("started convertion \r\n"); //just for knowing the status

CS5460_DRDY_reset(); //ignore the first computation cycle

while(1)
{

if(CS5460_DRDY_ready())
{
Vrms = CS5460_read_24bit(REG_VRMS);
Irms = CS5460_read_24bit(REG_IRMS);
Energy = CS5460_read_24bit(REG_ENERGY);

CS5460_DRDY_reset();

}

}

}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…