ESP32-S3 SPI hangs after using HIGHPART (silicon bug?)

pg_esp32
Posts: 3
Joined: Tue Nov 15, 2022 12:44 pm

ESP32-S3 SPI hangs after using HIGHPART (silicon bug?)

Postby pg_esp32 » Wed Jan 04, 2023 9:28 am

To create very efficient code to write to an SPI LCD I tried to alternate between SPI_W0_REG..W7 and W8..W15.
While the SPI is sending out the data, the CPU will calculate and fill the other range in place. So the gap between transaction only consists of toggling usr_mosi_highpart and starting a transaction.

However the first transaction using W0 after a transaction using W8 does never complete (actually not starts because nothing is sent out). (transfer C in the example)

Sample code:

Code: Select all

   printf("init\n");

   // CS handling done with direct IO and omitted in this example as well as any pin and GPIO-matrix setup

   periph_ll_enable_clk_clear_rst(SPI_MODULE);
   GPSPI3.clk_gate.val = 7;
   GPSPI3.ctrl.val = 0;
   GPSPI3.user1.val = 0;
   GPSPI3.user2.val = 0;
   GPSPI3.clock.clkcnt_l = 39;
   GPSPI3.clock.clkcnt_h = 19;
   GPSPI3.clock.clkcnt_n = 39;
   GPSPI3.clock.clkdiv_pre = 1;
   GPSPI3.clock.clk_equ_sysclk = 0;
   GPSPI3.misc.val = 0;
   GPSPI3.user.val = 0;
   GPSPI3.user.usr_mosi = 1;
   GPSPI3.ms_dlen.val = 7;

   printf("transfer lo A\n");

   GPSPI3.data_buf[0] = 'A';
   SPI_DEV.cmd.update = 1;
   while (SPI_DEV.cmd.update) {}
   SPI_DEV.cmd.usr = 1;
   while (SPI_DEV.cmd.usr) {}

   printf("transfer hi B\n");

   GPSPI3.user.usr_mosi_highpart = 1;
   GPSPI3.data_buf[8] = 'B';
   SPI_DEV.cmd.update = 1;
   while (SPI_DEV.cmd.update) {}
   SPI_DEV.cmd.usr = 1;
   while (SPI_DEV.cmd.usr) {}

   printf("transfer lo C\n");

   GPSPI3.user.usr_mosi_highpart = 0;
   GPSPI3.data_buf[0] = 'C';
   SPI_DEV.cmd.update = 1;
   while (SPI_DEV.cmd.update) {}
   SPI_DEV.cmd.usr = 1;
   while (SPI_DEV.cmd.usr) {}

   printf("done\n");

Who is online

Users browsing this forum: No registered users and 14 guests