cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 DCMI connected to TVP5150 (PAL to digital ITU-R BT.656 convertor)

FVese.1
Associate

Camera (Micro 600TVL) works fine when connected to TV. Using I2C, I set up the embedded synchronization (can´t use external) on the TVP and enabled the outputs. TVP status registers say: Vertical and horizontal sync is locked, Color subcarrier is locked. In CubeIde I set DCMI and DMA (see photo) and turned on receiving in SNAPHOT mode. Only 1440 bytes were transferred to the buffer = one line. The NDTR register remains non-zero. The CAPTURE bit in DCMI_CR is cleared. The next lines are ignored and the HAL_DCMI_FrameEventCallback function is called. Don't you know how to receive all lines?

//DCMI INIT BY HALL (COMMENTS REMOVED)
static void MX_DCMI_Init(void)
{
  hdcmi.Instance = DCMI;
  hdcmi.Init.SynchroMode = DCMI_SYNCHRO_EMBEDDED;
  hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
  hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
  hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
  hdcmi.Init.SyncroCode.FrameEndCode = 0xB6;
  hdcmi.Init.SyncroCode.FrameStartCode = 0xAB;
  hdcmi.Init.SyncroCode.LineStartCode = 0x80;
  hdcmi.Init.SyncroCode.LineEndCode = 0x9D;
  hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE;
  hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
  hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
  hdcmi.Init.LineSelectMode = DCMI_LSM_ALTERNATE_2;
  hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
  if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
  {
    Error_Handler();
  }
  __HAL_DCMI_ENABLE_IT(&hdcmi, DCMI_IT_FRAME);  //I added this
}
 
//DMA INIT BY HALL
static void MX_DMA_Init(void)
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA2_CLK_ENABLE();
  HAL_NVIC_SetPriority(DMA2_Stream7_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream7_IRQn);
}
 
//VARIABLES, DEFINES
#define BUFFLENGTH 260100 //255*255*4(bytes on pixel), in future i will use crop
uint8_t buffDMA[BUFFLENGTH];
uint32_t lines = 0; //lines = 1 after DMA transfer
uint32_t vsync = 0; //vsync = 1  after DMA transfer
 
//MAIN
HAL_StatusTypeDef dmaStatus = HAL_OK;
dmaStatus = HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t) buffDMA, (uint32_t) BUFFLENGTH / 4); //dma status = HALL_OK after transfer
 
//FUNCTIONS
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) {
	lines++;
}
 
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) {
	vsync++;
}
 
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) {
	printf("DCMI has frame!\n\r"); //in console after transfer: "DCMI has frame!"
}

0693W000008FyoXQAS.jpg0693W000008FyWxQAK.pngAny help will be highly appreciated, thanks in advance!

1 REPLY 1
JGiem.1
Associate III

I know this is two years old now, but have you found a solution in the meantime? Having some trouble with the 5150AM aswell