![shequ.stmicroelectronics.cn](./template/st_v1/static/img/logo2.png)
使用nucleo-h745zi-q驱动OV2640 dcmi使用cubemx初始化后直接连线 具体为PC6, PC7, PC8, PC9, PD3, PE4, PE5, PE6-D0, D1, D2, D3, D4, D5, D6, D7 PA4-HREF PG9-VSYNC PB6-SCL PB7-SDA PD12-PWDN PD13-RST 左边是板子的右边是OV2640上的引脚 还有一个NC悬空 现在SCCB通信在示波器上看正常 但是回传数据均为0 程序主函数如下 /* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "string.h" #include <stdio.h> /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "ov2640.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ #ifndef HSEM_ID_0 #define HSEM_ID_0 (0U) /* HW semaphore 0*/ #endif /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma location=0x30000000 ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ #pragma location=0x30000080 ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ #elif defined ( __CC_ARM ) /* MDK ARM Compiler */ __attribute__((at(0x30000000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ __attribute__((at(0x30000080))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ #elif defined ( __GNUC__ ) /* GNU Compiler */ ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */ ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */ #endif ETH_TxPacketConfig TxConfig; DCMI_HandleTypeDef hdcmi; DMA_HandleTypeDef hdma_dcmi; ETH_HandleTypeDef heth; UART_HandleTypeDef huart3; /* USER CODE BEGIN PV */ HAL_StatusTypeDef dcmi_dma_status = HAL_OK; uint8_t ov2640_verh = 0xff, ov2640_verl=0xff; uint32_t dcmi_data_buff[16000]={0}; uint32_t DCMI_RN = 0; //row number uint32_t DCMI_CN = 0; //column number uint32_t DCMI_RS = 0; //row start uint32_t DCMI_CS = 0; //column start uint8_t tx_busy = 0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_DCMI_Init(void); static void MX_ETH_Init(void); static void MX_USART3_UART_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) PUTCHAR_PROTOTYPE { USART3->TDR = ch; while(!(USART3->ISR& USART_ISR_TXE_TXFNF_Msk)) {;} return ch; } void Send(uint8_t *pData,int jpglen) { uint32_t i = 0; //printf("jpeg data size:%d\r\n",JPEG_BUFFER_LENGTH); HAL_Delay(1000); for(i = 0;i < jpglen;i++) { //printf("%02x\t",pData); printf("%c",pData); } HAL_Delay(1000); printf("\r\n"); } void PY_OV2640_RGB565_CONFIG(void) { /*Camera Interface*/ SCCB_Rst(); //hard reset HAL_Delay(100); //SCCB_WR_Reg(0xff, 0x01); //soft reset //SCCB_WR_Reg(0x12, 0x80); //HAL_Delay(100); ov2640_verh = SCCB_RD_Reg(0x1c); HAL_Delay(50); ov2640_verl = SCCB_RD_Reg(0x1d); HAL_Delay(50); while ((ov2640_verh==0xff)||(ov2640_verl==0xff)) { HAL_UART_Transmit(&huart3, &ov2640_verh, 1, 0xFFFFFF); HAL_Delay(500); HAL_UART_Transmit(&huart3, &ov2640_verl, 1, 0xFFFFFF); HAL_Delay(500); } OV2640_UXGA_Init(); //pix speed adjustment SCCB_WR_Reg(0xff, 0x00); SCCB_WR_Reg(0xd3, 0x00); SCCB_WR_Reg(0XFF, 0X01); SCCB_WR_Reg(0X11, 0x01); OV2640_RGB565_Mode(); OV2640_OutSize_Set(640, 480); HAL_Delay(200); } /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* USER CODE BEGIN Boot_Mode_Sequence_0 */ int32_t timeout; /* USER CODE END Boot_Mode_Sequence_0 */ /* USER CODE BEGIN Boot_Mode_Sequence_1 */ /* Wait until CPU2 boots and enters in stop mode or timeout*/ timeout = 0xFFFF; while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0)); if ( timeout < 0 ) { Error_Handler(); } /* USER CODE END Boot_Mode_Sequence_1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN Boot_Mode_Sequence_2 */ /* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of HSEM notification */ /*HW semaphore Clock enable*/ __HAL_RCC_HSEM_CLK_ENABLE(); /*Take HSEM */ HAL_HSEM_FastTake(HSEM_ID_0); /*Release HSEM in order to notify the CPU2(CM4)*/ HAL_HSEM_Release(HSEM_ID_0,0); /* wait until CPU2 wakes up from stop mode */ timeout = 0xFFFF; while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0)); if ( timeout < 0 ) { Error_Handler(); } /* USER CODE END Boot_Mode_Sequence_2 */ /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_DCMI_Init(); MX_ETH_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ PY_OV2640_RGB565_CONFIG(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ dcmi_dma_status = HAL_DCMI_Init(&hdcmi); for (uint8_t i=0; i<10;i++) { HAL_DCMI_DisableCrop (&hdcmi); DCMI_RN = 48; DCMI_CN = 1280; DCMI_RS = 48*i; DCMI_CS = 0; HAL_DCMI_ConfigCrop (&hdcmi, DCMI_CS, DCMI_RS, DCMI_CN, DCMI_RN); HAL_Delay(1); HAL_DCMI_EnableCrop (&hdcmi); HAL_Delay(1); dcmi_dma_status = HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, dcmi_data_buff, DCMI_CN*DCMI_RN/4); while(HAL_DMA_GetState(&hdma_dcmi)==HAL_DMA_STATE_BUSY) ; HAL_DCMI_Stop(&hdcmi); tx_busy = 1; Send((uint8_t *)dcmi_data_buff, 61440); while(tx_busy!=0) ; } } /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ |
dcmi配置引脚
dcmi配置dma
程序运行结果
当io引脚接0v时,stm32h750 ADC获取值跳动特别大。接上待测电量直接就是满值,这个是什么原因导致?有什么办法可以解决?
stm32h743vit芯片在使能dma1时钟之后,sram_d2的内容会改成其他值
STM32H725RGV6 電源規劃
搜所了博客用stm32cubemx写一个简单adc获取值的例子 ,烧录到板子里导致芯片(STM32H750XBH6)锁死(怀疑配置的时钟频率和板子要求的不一样),不知道如何解除 芯片死锁。
STM32H747-DISCO烧录问题
stm32h745iit6通过stm32cubeprogrammer的usb进行iap时无法正确连接的问题
如何调整CubeMX的默认引脚
STM32H7RS-DK如何调试阶段在EXTRAM中烧写代码并进行调试。
STM32H7S78-DK ADC参考电压选择。
STM32H7A3LIH6Q PG12 PG13引脚无输出