7 years, 8 months ago.

DCMI on DISCO-F746NG and BSP_CAMERA stalls (OV9655, STM32F4DIS-CAM)

Has anyone got this camera working on the DISCO-F746NG? I'm struggling with the DISCO-F746NG and STM32F4DIS-CAM. The driver suggests it's a straightforward matter of Initialise and Start, but that isn't the end of the story by any means. If you do that it doesn't return from BSP_CAMERA_Init.

It looks like it is getting stuck in a DCMI interrupt. I say this because if I add the line return CAMERA_NOT_SUPPORTED; after the HAL_DCMI_Init(phdcmi); line (in stm32746g_discovery_camera.c) I see the first few characters of the next line of console output.

Removing the added return CAMERA_NOT_SUPPORTED; line and putting CAMERA_Suspend(); in its place allows the BSP_CAMERA_Init function to return and the code to run through until the BSP_CAMERA_Resume() function call.

I have added some interrupt code to main.cpp but that doesn't help. Any ideas?

Here is my full code (except the changes mentioned above to stm32746g_discovery_camera.c):

#include "mbed.h"
#include "SDRAM_DISCO_F746NG.h"
#include "stm32746g_discovery_camera.h"
//#include "stm32746g_discovery.h"

Serial pc(USBTX, USBRX);

//SDRAM_DISCO_F746NG sdram;

void DCMI_IRQHandler(void) {
    BSP_CAMERA_IRQHandler();
}

void DMA2_Stream1_IRQHandler(void) {
    BSP_CAMERA_DMA_IRQHandler();
}

int main()
{
    pc.baud(115200);
    pc.printf("START\r\n");
    wait_ms(1000);
    #define CAMERA_FRAME_BUFFER         0xC0260000
    #define LCD_FRAME_BUFFER                  0xC0130000
    #define resolution      RESOLUTION_R320x240
    
    pc.printf("HAL_Init()\r\n");
    HAL_Init();
    
    pc.printf("BSP_CAMERA_Init(resolution);\r\n"); 
    if( BSP_CAMERA_Init(resolution) == CAMERA_OK ) {
        pc.printf("OK\r\n");
    } else {
        pc.printf("Err\r\n");
    }
    pc.printf("BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);\r\n");
    wait_ms(100);
    BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
    //BSP_CAMERA_SnapshotStart((uint8_t *)CAMERA_FRAME_BUFFER);
    pc.printf("Camera running\r\n");
    
    HAL_Delay(1000);
    pc.printf("BSP_CAMERA_Resume();\r\n");
    wait_ms(100);
    BSP_CAMERA_Resume();
    HAL_Delay(1000);
    pc.printf("BSP_CAMERA_Suspend();\r\n");
    wait_ms(100);
    BSP_CAMERA_Suspend();
    
    pc.printf("BSP_CAMERA_Suspend-ed\r\n");
    
    while(1);    
}

The key here was that the Interrupt Handlers should have had extern "C" linkage as the library file is a *.c whereas the handlers are in main.cpp. So adding extern "C" { before void DCMI_IRQHandler(void) and a } after the DMA2_Stream1_IRQHandler function in main.cpp fixed it. No need for changes to any of the library files(e.g. stm32746g_discovery_camera.c)

posted by Chris P 09 Aug 2016

1 Answer

6 years ago.

My program is getting stuck after BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);

Did you run into this issue or change any other files not mentioned?