cancel
Showing results for 
Search instead for 
Did you mean: 

How to change camera resolution (IMX335 on MB1854B module) with STM32N6570-DK board?

saikumar
Senior

Hello everyone,

I am currently working with the STM32N6570-DK board and the MB1854B ST camera module.
For testing purposes, I have compiled and run the following example from ST's GitHub repository:

https://github.com/STMicroelectronics/STM32CubeN6/tree/main/Projects/STM32N6570-DK/Applications/DCMIPP/DCMIPP_ContinuousMode .

In this example, the camera operates at a resolution of 2592x1944.

Now, I would like to change the camera configuration to capture video at a lower resolution, such as 640x480 or 384x288.

Could someone please guide me on:

  • How to configure the camera for 640x480 or 384x288 resolution?

  • Are there specific register changes needed for the IMX335 sensor?

  • I have checked the IMX335 datasheet, but I couldn’t find register-level details—where can I find the correct registers or configuration sequence?

Any help or code snippet showing how to set a different resolution would be greatly appreciated.

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

Sensor Output Resolution vs. Register Settings

Thank you for your detailed observations. Regarding the discrepancy between the README example and the register settings:

According to the sensor data sheet the availbale resolution is 2592x1944.

However, the actual output resolution sent to the LCD/display pipeline is controlled by additional configuration layers, including the DCMIPP (Digital Camera Memory Interface Pixel Processor) and downsize settings.

In the example, even if the sensor is internally set to 2592x1944, the DCMIPP and downstream processing block resizes or crops the image to 800x480 before it reaches the LCD (here dcmipp - downsize is used)

This approach allows the sensor to operate in a full-resolution mode (for example, to maintain image quality or for post-processing) but outputs a scaled-down frame to the display.The sensor registers may be configured for 2592x1944, but the effective output after processing is 800x480, as controlled by the DCMIPP and related configurations.


BUFFER_ADDRESS and Memory Usage

Regarding the memory address:

The address 0x34200000 points to internal memory, specifically AXISRAM3 (refer to section 2.3.2 "Memory map and register boundary addresses" in the Reference Manual).

Since the DCMIPP configuration sets the output size to 800x480 with 2 bytes per pixel (likely RGB565 or similar), the allocated buffer size is:

800×480×2=768,000 bytes≈750 KB

This size fits comfortably within this RAM.

Configuring  640x480 resolution:

You can use either Crop or Downsize features of the DCMIPP to fit your application constraints, with Downsize being the recommended approach.

 

For downsize , refer to the chapter 39.7.4 Downsize in the referance Manual of N6 for software configuration:

STM32N647/657xx Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual

For each value a formula is provided withinregiter description part (sections 39.14.71 & 39.14.72)

The division factor is an unsigned integer based on the source/destination ratio:
div = max(int(1024 / (source/destination)), 1023)

The down scale ratio is expressed in unsigned 3.13 format:
ratio = max(int((SourceSize - 1) / (DestinationSize -1)) * 8192), 8 * 8192 - 1)

 

Best Regards.

 

View solution in original post

4 REPLIES 4
Ch_JE
ST Employee

Hello,

To configure the camera resolution, you typically adjust the sensor registers responsible for image size, windowing, and scaling. For the IMX335 sensor, this process includes:

  • Updating the registers that define the output image size.
  • Modifying timing-related registers such as frame length and line length.
  • Potentially changing scaling or binning parameters if the sensor supports these features.

ST usually supplies sensor drivers or register configuration files within their firmware or Board Support Package (BSP).

Practical steps to follow:

  • Check ST’s BSP/Driver Package:
    The STM32CubeN6 package for your hardware typically contains sensor driver files located in folders like Drivers/BSP/Components/imx335/. These files include initialization sequences and register settings for various supported resolutions.

  • Identify Supported modes:
    Within driver source files (for example, imx335.c or imx335_reg.c), you will find different operating modes.

  • Modify or Create a Configuration for 640x480 or 384x288:
    The sensor’s datasheet lists 2592x1944 as the supported resolution.

Could you please share the constraints you are facing with the available configuration?

Regards

hello,@Ch_JE.

1 .  I would like to confirm something regarding the example provided in the README. It mentions configuring the sensor to output 800x480 resolution and displaying it on the LCD at 800x480.

  • However, when I checked the code, I noticed that some  registers—specifically HNUM  and AREA3_WIDTH_1  are actually configured for 2592x1944 resolution.
    This created some confusion for me: based on the current register settings, is the sensor really outputting 800x480 or 2592x1944?

2 . In the code, I see the line:

#define BUFFER_ADDRESS 0x34200000

 

  • Is this address pointing to internal RAM or external memory?

  • And if external, what type of memory is being used?

 

I’m asking because if the sensor is actually outputting at 2592x1944, the raw frame size would be around 5 MB .
But the internal RAM in the MCU is far less than that—so how is that data being stored?

Additionally, the DCMIPP configuration sets HSize and VSize to 800x480, then does it allocate and store only:

800 * 480 * 2 = 768,000 bytes   at that memory address?

 

3 .   And i attempted to configure the sensor to output 640x480 resolution using the following settings:

1 . HNUM 

{0x302e, 0x80},
{0x302f, 0x02},    // 0x0280 = 640 pixels

2 . AREA3_WIDTH_1

{0x3076, 0xc0},
{0x3077, 0x03},    // 0x03C0 = 960 (480 lines * 2)

>>> Set AREA3_WIDTH_1 to twice the number of the lines  . given in datasheet

3. Y_OUT_SIZE 

{0x3056, 0xe0},
{0x3057, 0x01},  // 0x01E0 = 480 lines

 

4.  changes for DCMIPP Configuration.

pPipeConf.PixelPipePitch  = 1280 ;    // 640 * 2

DonwsizeConf.HSize = 640 ;     //800 ; 
DonwsizeConf.VSize = 480 ; 

 

5 . changes for LTDC Configuration :

pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 640 ;   //Width;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 480 ;   //Height;

 

 

but the image displayed on the LCD is not as expected.

Interestingly, I get the exact same output image on the LCD that @saib mentioned in this discussion:

https://community.st.com/t5/stm32-mcus-embedded-software/how-to-understand-configuration-of-downsize-of-imx335-camera-in/m-p/812223#M64575 

Could you please guide me on what further changes are needed to get the output correctly at 640x480 resolution?

Thank you.

 

Hello,

Sensor Output Resolution vs. Register Settings

Thank you for your detailed observations. Regarding the discrepancy between the README example and the register settings:

According to the sensor data sheet the availbale resolution is 2592x1944.

However, the actual output resolution sent to the LCD/display pipeline is controlled by additional configuration layers, including the DCMIPP (Digital Camera Memory Interface Pixel Processor) and downsize settings.

In the example, even if the sensor is internally set to 2592x1944, the DCMIPP and downstream processing block resizes or crops the image to 800x480 before it reaches the LCD (here dcmipp - downsize is used)

This approach allows the sensor to operate in a full-resolution mode (for example, to maintain image quality or for post-processing) but outputs a scaled-down frame to the display.The sensor registers may be configured for 2592x1944, but the effective output after processing is 800x480, as controlled by the DCMIPP and related configurations.


BUFFER_ADDRESS and Memory Usage

Regarding the memory address:

The address 0x34200000 points to internal memory, specifically AXISRAM3 (refer to section 2.3.2 "Memory map and register boundary addresses" in the Reference Manual).

Since the DCMIPP configuration sets the output size to 800x480 with 2 bytes per pixel (likely RGB565 or similar), the allocated buffer size is:

800×480×2=768,000 bytes≈750 KB

This size fits comfortably within this RAM.

Configuring  640x480 resolution:

You can use either Crop or Downsize features of the DCMIPP to fit your application constraints, with Downsize being the recommended approach.

 

For downsize , refer to the chapter 39.7.4 Downsize in the referance Manual of N6 for software configuration:

STM32N647/657xx Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual

For each value a formula is provided withinregiter description part (sections 39.14.71 & 39.14.72)

The division factor is an unsigned integer based on the source/destination ratio:
div = max(int(1024 / (source/destination)), 1023)

The down scale ratio is expressed in unsigned 3.13 format:
ratio = max(int((SourceSize - 1) / (DestinationSize -1)) * 8192), 8 * 8192 - 1)

 

Best Regards.

 

Hello, mr @Ch_JE 

Thank you for your clarification sir.

I'd like to clarify a few technical points related to sensor resolution, DCMIPP downsizing, and memory handling based on my understanding and experimentation with the  example project.

1. Bandwidth Consumption: Sensor Resolution vs. Downsize Output?

If the sensor is configured to output at full resolution (e.g., 2592x1944), but DCMIPP is configured to downsize the image to 800x480, does the system bandwidth (memory interface or data path) still handle the full-resolution data, or only the downsized resolution?


2. Ratio and Division Factor Calculations.
Based on the reference manual and by your suggestion, I calculated the ratio and division factors for 800x480 downsize from a 2592x1944 sensor as:

HRATIO = floor(8192 × (2592 / 800)) = 26542;
VRATIO = floor(8192 × (1944 / 480)) = 33177;

HDIV = floor((1024 * 8192 - 1) / HRATIO) = 316;
VDIV = floor((1024 * 8192 - 1) / VRATIO) = 252;

But the sample code provides:

https://github.com/STMicroelectronics/STM32CubeN6/blob/main/Projects/STM32N6570-DK/Applications/DCMIPP/DCMIPP_ContinuousMode/FSBL/Src/main.c#L326 

DonwsizeConf.HRatio = 25656;
DonwsizeConf.VRatio = 33161;

DonwsizeConf.HSize = 800;
DonwsizeConf.VSize = 480;
DonwsizeConf.HDivFactor = 316;
DonwsizeConf.VDivFactor = 253;

Could explain why these values are set to little bit different ? or my calculation is wrong? 

3. Buffer Allocation Issue in Keil (No Space available)?

Error: L6406E: No space in execution regions with .ANY selector matching main.o(.bss.DCMIPP_DATA).

I replaced BUFFER_ADDRESS  with a local global buffer:

-->> unsigned char DCMIPP_DATA[800 * 480 * 2]; // ~750 KB

--->> if (HAL_DCMIPP_CSI_PIPE_Start(&hdcmipp, DCMIPP_PIPE1, DCMIPP_VIRTUAL_CHANNEL0 , DCMIPP_DATA /*BUFFER_ADDRESS*/, DCMIPP_MODE_CONTINUOUS) != HAL_OK)
---> >pLayerCfg.FBStartAdress = (uint32_t)DCMIPP_DATA ;     //BUFFER_ADDRESS

 

Even though my STM32 has 4.2 MB of RAM, Keil says there's no space.

 

Any help or clarification from ST experts or the community would be greatly appreciated.

Thanks,