Skip to main content
Visitor II
October 25, 2023
Question

STM32H7A3 DCMI does not capture data.

  • October 25, 2023
  • 3 replies
  • 2773 views

Hello everyone.

I've got a problem running DCMI interface on STM32H7A3 MCU. I'm using NUCLEO-H7A3ZI devboard and OV7670 camera module. Installed the latest CubeIDE and generated code in builtin configurator. Actually I'm using Segger Embedded Studio for development and debug but this does not seem to be a reason.

I configured camera module and can confirm that all data and syncro signals are correct. Frame buffer is 153600 bytes size for 320*240 16 bits image. DCMI is able to detect VSYNC and HSYNC pulses and generates interrupts, so framing is working as expected. DMA seems to work as well, I can see data in buffer. The problem is that I receive 1176 bytes of 0x08 and then all zeroes. According to debug info DCMI data register really gets 0x08 and 0x00 bytes, packs them to words and buffers for the further DMA transfer. I'm curios why port is not reading correctly? I tried to cover camera lens and tried set camera to transmit color bars in demo mode. Also played with master clock frequency changing pixel clock from 1.5 to 6 MHz. Result is always the same despite I see the real pixel data on bus with oscilloscope. 

Does anyone faced the same issue or can provide any thoughts?

Any help is apreciated!

Regards, 

Dmitriy.

 

 

 image.pngimage.png

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    October 26, 2023

    Hello @Dmitriy_L and welcome to the Community :),

    Could you please check if Capture bit is enabled in DCM_CR register?

    Note that the DMA controller and all DCMI configuration registers must be programmed correctly before enabling the CAPTURE bit in DCMI_CR. 

    May be 8. DCMI application examples section shared in AN5020 can help you.

    Thank you.

    Kaouthar

    Dmitriy_LAuthor
    Visitor II
    October 30, 2023

    Hello @KDJEM.1 ,

    Thank you for responce! 

    I believe that calling HAL_DCMI_Start_DMA function should enable CAPTURE bit in register, and it actually does:

    Dmitriy_L_0-1698655817722.png

    I've read AN5020 and found official examples on Github, however there is no examples for H7A3 all that I found are targeted for F747 MCU.Also I can confirm that DCMI configured before sampling started and that DMA is confugured prior to DCMI initialization. Here is my code snippets:

    void OV7670_Init(void)
    {
    if (cam_ctx.state == CAM_ST_NOINIT)
    {
    OV7670_HWReset();
    MX_I2C4_Init();
    MX_DCMI_Init();
    
    memset(cam_buf, 0, sizeof(cam_buf));
    if (SetupCam() == true)
    {
    cam_ctx.state = CAM_ST_IDLE;
    OV7670_Start();
    }
    else
    HAL_I2C_DeInit(&hi2c4);
    }
    }
    
    //------------------------------------------------------------------------------
    void OV7670_Start(void)
    {
    if (cam_ctx.state == CAM_ST_IDLE)
    {
    if (hdcmi.State == HAL_DCMI_STATE_READY)
    {
    cam_ctx.state = CAM_ST_BUSY;
    frame_ctx.sampling_active = false;
    frame_ctx.start_trig = true;
    frame_ctx.line_cntr = 0;
    frame_ctx.data = cam_buf;
    //frame_ctx.dbg = 0;
    
    memset(cam_buf, 0, sizeof(cam_buf));
    uint32_t buf_addr = (uint32_t)cam_buf;
    HAL_StatusTypeDef ret = HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, buf_addr, sizeof(cam_buf) / 4);
    assert_param(ret == HAL_OK);
    }
    }
    }
    
    Technical Moderator
    November 1, 2023

    Hi @Dmitriy_L ,

    Could you please check:

    - If the PSIZE bits in DMA_SxCR register are "10"? 

    - The programmed value in DMA_SxNDTR must be a multiple of MSIZE or PSIZE.

    Thank you.

    Kaouthar

    Dmitriy_LAuthor
    Visitor II
    November 10, 2023

    Hi @KDJEM.1 ,

    Sorry for the late responce, had some work on another project.

    I've checked registers you mentioned above:

    Dmitriy_L_0-1699633432590.png

    MSIZE and PSIZE both have 0x2 value. NDTR register seems to keep reminder of data that expected to be recieved from camera. Initial value 156300 bytes minus 1176 transferred gives 152424 or 38106 in uits of 32-bit words.

    Thank you! 

    Visitor II
    March 21, 2024

    Hi @Dmitriy_L , 

    I have the same problem with STM32H743Z12 (Nucleo board). All capture data are 0 in DMA buffer. Did you solved your problem?

    Thank you

     

     Eric

    Dmitriy_LAuthor
    Visitor II
    March 22, 2024

    Hi @eop ,

    No, unfortunately. I've spent a lot of time trying to bring up this set and eventually moved to Raspberry PI + webcam. It appeared to be much easier and faster. There are lot of examples on official Github page for numerous ST MCUs that support DCMI but not for STM32H7A3, quite suspicious, heh? 

    If you going to make your own trials and get succeed, please write here the solution. 

    Thanks and good luck!

    Dmitriy.