This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CANNOT ABLE TO TRANSMIT data/address in UART

hi Ole BAUCK, my slave device is STPM33 ENERGY METER using this device we can calculate vrms,irms,real power,reactive power,energy and many more.. that device is not having comman address. we can use address from 00-8A. to read active power address is 0x5c.i.e my slave address. i added my complete code please do check and help me. MAIN CODE

int main(void)
{
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    uint32_t err_code;
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_ENABLED,
          false,
          UART_BAUDRATE_BAUDRATE_Baud9600
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOW,
                        err_code);

printf("\n\rStart: \n\r");
		
uint8_t st;
get: while(app_uart_get(&st)!=NRF_SUCCESS);// to receive char ,if 's' start the transmission
if(st=='s')
{
		while(1)
		{

	uint8_t data=0x5c;	//slave address	
			uint8_t ch;
		static	int i=0;
while(app_uart_put(data)!=NRF_SUCCESS);//to transmit slave address 
			
			printf("\r\n");
			while(1)
			{
				char arr[50];
				
     while(app_uart_get(&ch));// to receive power values
			arr[i++]=ch;//storing into a buffer	
				
				if((int)ch==13)
				{	
					LEDS_ON(LEDS_MASK);
				printf("\r\nstring=%s\r\n",arr);//to print the received data
		
				}
				
			}
		}
}//to close if

else goto get;
}//to close main

i have attached STPM33 data sheet also in my previous post . please help me. Thanks in advance

Parents Reply Children
No Data
Related