FelipeMdeO opened a new issue, #12897:
URL: https://github.com/apache/nuttx/issues/12897

   ### Description / Steps to reproduce the issue
   
   Hello All,
   
   I am trying use spi in esp32c6 DevKit M but I am facing issues.
   I tried use default spi example, it fails some time, please look image below:
   
![image](https://github.com/user-attachments/assets/fd2f6cbb-f1e3-45db-879e-a5a15fb7f8d4)
   So I used logic analyzer to try debug whats happen and spi app has strange 
behavior. I cannot get clocks and cannot see MISO/MOSI bits.
   Also, I implemented a app by myself and I had same behavior, I cannot see 
clocks and data using logic analyzer and oscilloscope.
   Follow my app example:
   
   ```
   #include <nuttx/config.h>
   #include <nuttx/spi/spi_transfer.h>
   #include <fcntl.h>
   #include <unistd.h>
   #include <stdio.h>
   #include <stdint.h>
   
   #include "spitool.h"
   
   #define SPI_BUS 2  // SPI bus number
   #define SPI_DEVICE 0  // SPI device (chip select)
   #define SPI_MODE 0  // SPI mode (0, 1, 2, 3)
   #define SPI_FREQUENCY 1000000  // SPI frequency (1 MHz)
   #define SPI_BITS 8  // Number of bits per SPI word
   #define SPI_DELAY 0  // Delay between transfers (in microseconds)
   
   void send_spi_data(int fd, uint8_t *txbuffer, int length)
   {
       struct spi_sequence_s seq;
       struct spi_trans_s trans;
   
       // Configure the transfer sequence
       seq.dev = SPIDEV_ID(SPIDEVTYPE_USER, SPI_DEVICE);
       seq.mode = SPI_MODE;
       seq.nbits = SPI_BITS;
       seq.frequency = SPI_FREQUENCY;
       seq.ntrans = 1;
       seq.trans = &trans;
   
       // Configure the transfer
       trans.deselect = true;
       trans.delay = SPI_DELAY;
       trans.nwords = length;
       trans.txbuffer = txbuffer;
       trans.rxbuffer = NULL;  // We are not receiving data
   
       // Perform the SPI transfer
       if (spidev_transfer(fd, &seq) < 0) {
           perror("SPI transfer failed");
       } else {
           printf("SPI transfer succeeded\n");
       }
   }
   
   int main(void)
   {
       int fd;
       uint8_t txbuffer[] = {0xDE, 0xAD, 0xBE, 0xEF};  // Known data buffer
   
       // Open the SPI device
       fd = spidev_open(SPI_BUS);
       if (fd < 0) {
           perror("Failed to open SPI device");
           return -1;
       }
   
       while (1) {
           // Send data via SPI
           send_spi_data(fd, txbuffer, sizeof(txbuffer));
   
           // Wait for 1 second
           sleep(1);
       }
   
       // Close the SPI device
       close(fd);
       return 0;
   }
   
   ```
   
   Below, follow logic analyzer and oscilloscope captures:
   
![image](https://github.com/user-attachments/assets/ddddfa15-de00-4057-b7a5-a0bab213c34d)
   
![image](https://github.com/user-attachments/assets/61281b23-de60-4c37-bdd5-5ecbcc24b4a5)
   
![image](https://github.com/user-attachments/assets/055e1a83-bb2c-49e6-a1d3-db6da4356b04)
   
![image](https://github.com/user-attachments/assets/69aa5c7c-3618-4478-9566-0033d2bee4da)
   
![image](https://github.com/user-attachments/assets/71f028e3-24f3-4044-9ed6-c1fc362faa9d)
   
   Please, anyone can check it in your side?
   
   ### On which OS does this issue occur?
   
   [Linux]
   
   ### What is the version of your OS?
   
   Ubuntu 23.1
   
   ### NuttX Version
   
   master
   
   ### Issue Architecture
   
   [risc-v]
   
   ### Issue Area
   
   [Applications], [Drivers]
   
   ### Verification
   
   - [X] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to