cancel
Showing results for 
Search instead for 
Did you mean: 

I am using STPM32 with UART communication. I am able to read all Default values as per datasheet. How to make the IC to start acquiring voltage current and update the respective registers.

GKish.1
Associate II
 
5 REPLIES 5

Show us what you already have done.

JW

GKish.1
Associate II

Thank you for your response

Below is the Arduino Mega code

int receivedByte = 0;

void setup()

{

 Serial.begin(9600); //MEGA TO PC

 Serial1.begin(9600); //MEGA TO STPM32

 delay(10);

}

void loop()

{

 Serial1.write(0x48); // register for voltage and current read address

 Serial1.write(0xFF); // no write ADDRESS so (0xFF)

 Serial1.write(0xFF); // WRITE DATA

 Serial1.write(0xFF); // WRITE DATA

 Serial1.write(0x22); //crc value after calcultion

 Serial.println("data sent: (48 FF FF FF 22) "); //Print in PC

 Serial.println();

 Serial.print("I received: ");

 while (Serial1.available() > 0)

 {

  receivedByte = Serial1.read();

  Serial.print(receivedByte, HEX); //here I'm receiving default value of all register

 }

 Serial.println();

 Serial.println();

 delay(1000);

}

Data recived for 48FFFFFF is 000000

Register for voltage and current

Data recieved for 0FFFFFF is A000475

//Register address 0x00 as per data sheet default value is 040000A0 (just the reverse of what i recived)

0693W00000JMdlkQAD.jpg48FFFFFF22 Transmit Data

0693W00000JMdm9QAD.jpgRevieve Data for 48FFFFFF22

0693W00000JMdmdQAD.jpg00FFFFFFF0 Transmit Data

0693W00000JMdmiQAD.jpgRecieve data for 00FFFFFFF0

GKish.1
Associate II

Do we need to send any initialization command ?

Didier HERROUIN
ST Employee

Hello,

No, you do not need to send any init command to get the chipset ready.

Nevertheless, you need to enable the "Data latch" to get the values latched in the data register (see register dsp_cr3):

  • either by enabling the automatic SW latch (bit 23): the data will be latched every 128µs
  • or by enabling the "manual" SW latches (bit 20 & 21) each time you want to read some data: the data will be latched until the moment you will read the register

Another option is to use the "manual" HW latch (pulse on signal SYN, see DS).

The content of the register 0 you received is correct (0xA0 00 00 04, as frame format is LSBfirst).

I put in attached an Application Note which should be very helpful for understand the UART communication for STPM3x and the init phase.

Best regards,

Didier Herrouin

Didier HERROUIN
ST Employee