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.

[AVR] Atmega644P interfacing CS5460A power meter

Status
Not open for further replies.

Alex Aldridge Arabaolaza

Newbie level 2
Joined
Jun 18, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
16
Hi mates. I'm really stuck trying to communicate both ATMega644P controller and a Cirrus Logic CS5460A power meter. I've read the datasheet carefully several times but I haven't been able to solve the problem yet. My problem is that the MISO line is always 0. I leave the code i use just in case you notice any kind of error.

Atmega644P is running @20Mhz while CS5460A is running @3.6864Mhz.

SPI initialization in ATMEGA644P:

Code:
/**
* Initialize and configure the SPI
* SPI Type: Master
* SPI Clock Rate: 1,25MHz
* SPI Clock Phase: Cycle Half
* SPI Clock Polarity: Low
* SPI Data Order: MSB First
*/
__C_task void InitSPI(void)
{
	SPCR0= (1<<SPE0) | (1<<MSTR0) | (1<<SPR00);
	SPSR0=0x00;
        SPI_initialized = TRUE;
}


Then I initialize the CS5460A by sending these commands:

Code:
void init_CS5460A_send_sequence(){
          
    CLRBIT(CS5460A_SS);                    //Enable CS5460A	
    for(int i = 0; i < 20000; i++);
    
    //Send Synchronization commands
    cs5460_sync();
    
    //soft reset
    cs5460_Write_data(CONFIG_REGISTER, 0x000080);

    //Resync
    cs5460_sync();
    
    //configure (x10 gain for current)
    cs5460_Write_data(CONFIG_REGISTER, 0x000061);
    
    //set integration period (72 clocks)
    cs5460_Write_data(CYCLE_COUNT_REGISTER, 0x000048);

    //reset all bits in status register (IC* bit ignored)
    cs5460_Write_data(STATUS_REGISTER, 0xFFFFFF);

    //set DRDY in mask register (for INT*)
    cs5460_Write_data(MASK_REGISTER, 0x800000);

    //start continuous computation cycles
    cs5460_send(0xE8);
    
    SETBIT(CS5460A_SS);                   //Disable CS5460A	
    for(int i = 0; i < 20000; i++);
}


And then, to retrieve data from CS5460A i use this code:

Code:
CLRBIT(CS5460A_SS);
      for(int i = 0; i < 20000; i++);
      cs5460_sync();
      cs5460_rst_st_reg();
      cs5460_Read_data(0x18);
      SETBIT(CS5460A_SS);
      for(int i = 0; i < 20000; i++);


I know the MISO line is always 0 as I looked carefully into it using an oscilloscope. The rest of the lines seem to be working fine. Do you have any idea about what can be going on?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top