2016-01-10 01:56 AM
I use stm32f4 discovery connect with camera OV767 to capture picture and send it to uart4. But when i use DCMI_Cmd(ENABLE); First, i just want send 'A' but i can't. What happening with DCMI or when i use DCMI, i must not use uart.
int main(){ char buf[50]; Delay_Init(); TFT_Init(); Init_Pin_Out(Pin_D12); Init_USART(USART3_Pack2,115200); TFT_Clear(Black); TFT_Puts(0, 0, ''Test DCMI OV7670'', White, Black); if(DCMI_OV7670_Init()==0) {TFT_Puts(0, 12, ''Init Done'', White, Black);} else {TFT_Puts(0, 12, ''Init Fail'', Red, Black);} LCD_SetCursor(0,0); LCD_REG = 0x0022; DMA_Cmd(DMA2_Stream1, ENABLE); DCMI_Cmd(ENABLE); DCMI_CaptureCmd(ENABLE); while(1) { //frame_buffer=0x12345678; //sprintf(buf,''%ld\n'',frame_buffer); //USART_Puts(UART4_Pack2,buf); USART_SendData(USART3,'A'); }} If i don't use DCMI_Cmd(ENABLE); i send 'A' to PC good. However, i use DCMI_Cmd(ENABLE) i can't send data. Please tell me what happening with DCMI or UARTThis is code config DCMIvoid DCMI_Config(void){ DCMI_InitTypeDef DCMI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOE,ENABLE); RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOE, GPIO_PinSource0, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOE, GPIO_PinSource1, GPIO_AF_DCMI); GPIO_PinAFConfig(GPIOE, GPIO_PinSource4, GPIO_AF_DCMI); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4; GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOA, &GPIO_InitStructure); DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous;//DCMI_CaptureMode_SnapShot;// DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware; DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling; DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_High; DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame; DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b; DCMI_Init(&DCMI_InitStructure); DCMI_ITConfig(DCMI_IT_VSYNC, ENABLE); DCMI_ITConfig(DCMI_IT_LINE, ENABLE); DCMI_ITConfig(DCMI_IT_FRAME, ENABLE); DCMI_ITConfig(DCMI_IT_ERR, ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); DMA_DeInit(DMA2_Stream1); DMA_StructInit(&DMA_InitStructure); DMA_InitStructure.DMA_Channel = DMA_Channel_1; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&DCMI->DR; DMA_InitStructure.DMA_Memory0BaseAddr = FSMC_LCD_ADDRESS;//(uint32_t)&frame_buffer[0]; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 0x01; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream1, &DMA_InitStructure);}2016-01-10 02:56 AM
2016-01-10 03:02 AM
Could you be locked into an interrupt loop ?
Is there an evidence that anything else is working after DCMI_Cmd(ENABLE) ? Try TFT prints.2016-01-10 03:59 AM
//frame_buffer=0x12345678;
//sprintf(buf,''%ld\n'',frame_buffer);//USART_Puts(UART4_Pack2,buf);USART_SendData(USART3,'A');i still use USART_SendData(USART3,'A'); for my code. First time, i use uart 4, then i decide use usart 3, i don't know what different between USART and UART. dear i don't understand what you mean, how can i lock interrupts. And i have a question, isn't that data in DCMI->DR is image data. Can i use it and send to uart. Like example:uint32_t data;char buf[20];buf=DCMI->DRsprintf(buf,''%lu'',data);USART_Puts(buf);2016-01-10 05:13 AM
A DCMI IRQ is enable, so it is likely the interrupt handler will run sooner or later. The trivial cause of your problem is that the default interrupt handler is an infinite loop that will lock up your application, blocking the UART communication and *anything* else.
2016-01-10 06:34 AM
You have to wait for TXE before jamming data out.
Don't selectively show code, it provides random context when you don't even know where the problem is.