Issue with AR0144 Sensor Integration Using DCMI-DMA on STM32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-21 12:24 AM
I am currently integrating the AR0144 sensor with STM32 using the DCMI interface with DMA for image capture. The image data is being received, but the issue is that the data is incomplete, and zeros are padded at the end of the buffer.
Hardware and Setup:
- MCU: STM32L4A6VGY6PTR
- Image Sensor: AR0144CS (AR0144CSSC00SUKA0-CPBR)
- Interface: DCMI with DMA
- Software: STM32 HAL with FreeRTOS
Current DCMI and DMA Configuration:
Here are the DCMI and DMA configurations I am using:
DCMI Configuration:
CopyEdit
hdcmi.Instance = DCMI;
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_12B;
hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
{
Error_Handler();
}
DMA Configuration:
c
CopyEdit
hdma_dcmi.Instance = DMA2_Channel5;
hdma_dcmi.Init.Request = DMA_REQUEST_4;
hdma_dcmi.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_dcmi.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_dcmi.Init.MemInc = DMA_MINC_ENABLE;
hdma_dcmi.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_dcmi.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_dcmi.Init.Mode = DMA_NORMAL;
hdma_dcmi.Init.Priority = DMA_PRIORITY_HIGH;
if (HAL_DMA_Init(&hdma_dcmi) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(&hdcmi, DMA_Handle, hdma_dcmi);
Observations:
- The image buffer receives data, but some frames are incomplete.
- Zeros are padded at the end of the buffer and then few consecutives frames are 0 and then whole process is repeated.
- The HAL_DCMI_FrameEventCallback is triggered, but not always as expected.
- The issue persists even after trying different buffer sizes and memory alignment configurations.
Any suggestions on modifying the DMA or DCMI settings to get a complete image buffer?
Any insights or suggestions would be greatly appreciated. Thank you in advance!
- Labels:
-
DMA
-
STM32L4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-24 7:58 AM
Hello @Vaishak-hoomanely and welcome to the community,
What is the image resolution?
Could you try with a low image resolution like 480x272?
I recommend you to take a look at AN5020 may help you.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-24 10:26 PM
Thank you @Kaouthar for your response.
We are already using a lower resolution - our current configuration is 320x200 with 12-bit data format (not 480x272). Even at this reduced resolution, we're encountering issues with image quality, not memory limitations.
Here's a summary of our current setup:
Camera: AR0144 CMOS sensor
Resolution: 320x200 (center crop from full sensor)
Data format: 12-bit with DCMI_EXTEND_DATA_12B
DCMI configuration:
VSPolarity = DCMI_VSPOLARITY_LOW
HSPolarity = DCMI_HSPOLARITY_LOW
PCKPolarity = DCMI_PCKPOLARITY_RISING
DMA in circular mode with word alignment
The camera initializes correctly:
I2C communication works (device found at address 0x33)
Chip ID verifies correctly (0x0356)
PLL configuration reads back as expected
DMA transfer appears to start
The issue is that while we're receiving data (the buffer gets filled and the frame callback triggers), the image data does not appear to be valid. We're getting base64-encoded output, but it doesn't decode to a recognizable image.
Our debugging logs show:
The camera initialization completes successfully
DCMI and DMA are configured correctly
The sensor goes into streaming mode
Frame events are triggered and our callback executes
But the resulting data appears to be corrupted or improperly formatted
Please have a look at the received data attached.
Thankyou
Vaishak C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 5:37 AM
Hello @Vaishak-hoomanely,
Thank you for updating post.
I think the issue is related to the priorities of the interrupts.
I propose you to disable the FreeRTOS and disable all other sources and keep only the DCMI interrupts (or you can set the DCMI at the high priority level) to check if the problem is resolved.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-25 6:01 AM
I have made progress in my AR0144 integration and moved past the PLL lock issue.
Current Issue: Frame Buffer Remains Empty :
Please check the log file that i have attached along with the DCMI DMA configs.
Also i am keeping the ar0144 initialization setting since i have added changes to overcome PLL not locking issue.
