cancel
Showing results for 
Search instead for 
Did you mean: 

I'm trying to interface my STM32F103C6 with ADE7753, So anyone can help me regarding this. I have made the hardware connection correctly but stuck with programming..

DKuma.10
Associate II
 
13 REPLIES 13
DKuma.10
Associate II

hello sir, now i'm able to get the values of IRMS and VRMS when i execute the program individually inside the while loop.

the problem here i face is when i try to get the values of IRMS and VRMS together , inside the while loop i get the correct reading with the incorrect values and so forth.

while (1) {

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

//voltage measurement

reg = reg_V|reg_r; //0x17|0x00

READ_24bit(reg); //function described below

V = (0.5 / 1551400.0 / sqrt(2)) * data * 476; //voltage calculation

sprintf(buffer1, "data=%ld, VRMS=%.2f \r\n", data, V); //uart

uprintf(buffer1);

HAL_Delay(10);

reg = reg_I|reg_r; //0x16|0x00

READ_24bit(reg); //function described below

I = (0.5 / 1868467.0 / sqrt(2)) * data / 10.0 * 1800; //current measurement

sprintf(buffer, " data=%ld,   IRMS=%.2f \r\n", data, I); //uart

uprintf(buffer);

HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);

HAL_Delay(100);

}

}

uint32_t READ_24bit(uint8_t reg) {

Slave_select();

data=0;

uint8_t data0=0, data1=0, data2=0;

DWT_Delay_us(10);

spi_transmit(reg); //transmit register value

DWT_Delay_us(25);

data0 = spi_transmit(0x00); //first 8 bit read operation

DWT_Delay_us(5);

data1 = spi_transmit(0x00); //second 8 bit read operation

DWT_Delay_us(5);

data2 = spi_transmit(0x00); //third 8 bit read operation

DWT_Delay_us(5);

Slave_deselect();

data = ((uint32_t) data0 << 16) | ((uint32_t) data1 << 8)| ((uint32_t) data2);

return data;

}

help me.

TDK
Guru

“i get the correct reading with the incorrect values and so forth�?

What the heck does that mean? If you want help on an internet forum, the better you lay our your problem the more helpful the responses can/will be.

If you feel a post has answered your question, please click "Accept as Solution".
DKuma.10
Associate II

answer me please.

I'm not able to debug this through a keyhole. You have code fragments, talking to a device I don't have, and no supporting data showing any of the registers, values read. intermediate computations. Your code outputs messages, don't see any of this output, or the data supporting it.

I don't seen any registers dumps, or scope output.

Best you work this out with your colleagues, and ST / Analog Devices support staff.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..