cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with STPM33 with TFT LCD on the same SPI BUS ?

JAtia.1
Associate

I'm working on Embedded Linux Meter ..

when trying to connect stpm33 to my board on spi1.0 .. it works fine.

and when trying to connect tft to my board on the same spi bus with different CS it also works fine. but when trying to connect both of them at the same time I face issue with TFT which is blank screen .. after some time of debugging I realized that becuase of STPM33 works with spi mode3 but TFT works with mode0 and the TFT works when disconnect CLK pin from STPM33 bus so I decided to use de-mux to select CLK pin goes to TFT or STPM33 based on the CS pin after that I found TFT LCD works fine but STPM33 gives me strange readings such as voltage = 1602.75 .. every time give me the same readings .. is there any solution to make the tft and stpm33 works on the same spi bus ?

here is the main function.

void MainProcess(void)

{

   char buf[100];

   gpio_init(STPM33_CS_Pin , "out" );

   gpio_init(STPM33_SYN_Pin , "out" );

   gpio_init(STPM33_EN_Pin , "out" );

   METRO_Init();

   printf("init done \n");

   sleep(2);

   while (1) {

      Metro_HAL_Set_Latch_device_type(LATCH_SW);

      Metro_HAL_Get_Data_device();

      METRO_Update_Measures();

      Voltage = (double) metroData.rmsvoltage / 1000.0;

      Current = (double) metroData.rmscurrent / 1000.0;

      ActivePower = metroData.powerActive / 1000.0;

      ActiveEnergy = metroData.energyActive;

      // write the readings into text file

      RecordReadings();

      sleep(2);

   }

}

0 REPLIES 0