完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
张工带你玩转STM32问答 高手问答第9期 小编导读: 简 介: 假如你在纠结如何才能将STM32中的图片保存到SD 假如你还在为捕获时出现频率跳变出现问题 。。。。。。 苦恼的话!!!! 或许你可以在本帖下面,跟帖+并@指上谈兵123张工,说不定你的问题在下个楼层或是下一页的楼层会有一个指引方向给你,或者是问题被解决了。 Elecfans高手问答,根据主题,回帖提问,解答你的疑惑。 ———————————————————————————————————————— 社区高手招募 ———————————————————————————————————————— *************问答精华*************** 往期回顾: 本帖被以下淘专辑推荐:
|
|
相关推荐
46 个讨论
|
|
|
int main(void) { unsigned char i,data; USART_InitTypeDef USART_InitStructure; RCC_Configuration(); GPIO_Configuration(); USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1,ENABLE); data = 'A'; for(i=0; i<10; i++) { USART_SendData(USART1,data); data++; while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET); } } 我明明循环了10次,却只打印出了9个数据,原本想输出“ABCDEFGHIJ”,但是实际输出出来的是“ACDEFGHIJ” 这是为什么呢?求大侠解惑 @指上谈兵123 |
|
|
|
|
|
|
|
|
找了很多例程,也反复看了数据手册,但还是有几个关键问题不太明白,求指教!!!
DAC_SetDualChannelData(DAC_Align_12b_L, 2047, 4095); DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE); DAC_SoftwareTriggerCmd(DAC_Channel_2,ENABLE); printf("rn The Value is : %d ,%drn",DAC_GetDataOutputValue(DAC_Channel_1),DAC_GetDataOutputValue(DAC_Channel_2)); 我是这样配置的,串口输出The Value is :255,,127 不是很明白这代表的是什么? 2、而且数据手册上说取值范围为0~4095,输出值是最大Vref,但是我调程序时把值设置成5095串口仍然输出,且值变大,不太明,输白这是为什么? 3、我想使用DA转换的值,但是手册上也有说明,GPIO口设置成AIN模式输入模式怎么输出数据呢,还是要设置其他什么值?@指上谈兵123 |
|
|
|
|
|
|
|
|
打开keil安装目录你会找到很多的例子的,比如我的安装目录是D:Program Files打开 D:Program FileskeilARMExamplesSTSTM32F10xFWLibExamplesGPIOIOToggle你会看到gpio的操作案例 例如下面代码 /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V2.0.1 * Date : 06/13/2008 * Description : Main program body. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_lib.h" #include "platform_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ GPIO_InitTypeDef GPIO_InitStructure; ErrorStatus HSEStartUpStatus; /* Private function prototypes -----------------------------------------------*/ void RCC_Configuration(void); void NVIC_Configuration(void); void Delay(vu32 nCount); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { #ifdef DEBUG debug(); #endif /* System Clocks Configuration **********************************************/ RCC_Configuration(); /* NVIC Configuration *******************************************************/ NVIC_Configuration(); /* Configure all unused GPIO port pins in Analog Input mode (floating input trigger OFF), this will reduce the power consumption and increase the device immunity against EMI/EMC *************************************************/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, DISABLE); #ifdef USE_STM3210E_EVAL RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, ENABLE); GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, DISABLE); #endif /* USE_STM3210E_EVAL */ /* Configure IO connected to LD1, LD2, LD3 and LD4 leds *********************/ /* Enable GPIO_LED clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_LED, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIO_LED, &GPIO_InitStructure); while (1) { /* Turn on LD1 */ GPIO_SetBits(GPIO_LED, GPIO_Pin_6); /* Insert delay */ Delay(0xAFFFF); /* Turn on LD2 and LD3 */ GPIO_SetBits(GPIO_LED, GPIO_Pin_7 | GPIO_Pin_8); /* Turn off LD1 */ GPIO_ResetBits(GPIO_LED, GPIO_Pin_6); /* Insert delay */ Delay(0xAFFFF); /* Turn on LD4 */ GPIO_SetBits(GPIO_LED, GPIO_Pin_9); /* Turn off LD2 and LD3 */ GPIO_ResetBits(GPIO_LED, GPIO_Pin_8 | GPIO_Pin_7); /* Insert delay */ Delay(0xAFFFF); /* Turn off LD4 */ GPIO_ResetBits(GPIO_LED, GPIO_Pin_9); } } /******************************************************************************* * Function Name : RCC_Configuration * Description : Configures the different system clocks. * Input : None * Output : None * Return : None *******************************************************************************/ void RCC_Configuration(void) { /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if(HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } } /******************************************************************************* * Function Name : NVIC_Configuration * Description : Configures Vector Table base location. * Input : None * Output : None * Return : None *******************************************************************************/ void NVIC_Configuration(void) { #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif } /******************************************************************************* * Function Name : Delay * Description : Inserts a delay time. * Input : nCount: specifies the delay time length. * Output : None * Return : None *******************************************************************************/ void Delay(vu32 nCount) { for(; nCount != 0; nCount--); } #ifdef DEBUG /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert_param error has occurred. * Input : - file: pointer to the source file name * - line: assert_param error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(u8* file, u32 line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %drn", file, line) */ /* Infinite loop */ while (1) { } } #endif /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ |
|
|
|
|
|
1 条评论
|
|
|
|
|
|
|
|
|
|
|
|
现在用的ST32+1963主要是点液晶屏TFT,现在点了一款分辯率是480*800的屏
屏用的IC是HX8369,点屏的时候要设置前后肩,在网上找了这些数组,下面这些值是怎么算出来的呢, 看了一下1963的规格书,就是B4与B6寄存器,但还是不知道怎么算出来的,请大侠们,大哥们指点一下 谢谢 #define LCD_HDP 799(只知道这个是屏的点阵) #define LCD_HT 1000 #define LCD_HPS 51 #define LCD_LPS 3 #define LCD_HPW 8 #define LCD_VDP 479(只知道这个是屏的点阵) #define LCD_VT 530 #define LCD_VPS 24 #define LCD_FPS 23 #define LCD_VPW 3 |
|
|
|
|
|
|
|
|
static __INLINE uint32_t SysTick_Config(uint32_t ticks)
{ if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; //尤其是对寄存器操作这句 return (0); } 这段代码不是很懂 求大神解释! |
|
|
|
|
|
|
|
|
就是SD_PowerON那个函数下,他写的发送完cmd0,然后发送cmd8/*---------------------cmd8------*/
SDIO_CmdInitStructure.SDIO_Argument = SD_CHECK_PATTERN; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_SEND_IF_COND; //CMD8 SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp7Error(); if (errorstatus == SD_OK) { CardType = SDIO_STD_CAPACITY_SD_CARD_V2_0; SDType = SD_HIGH_CAPACITY; } else { SDIO_CmdInitStructure.SDIO_Argument = 0x00; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_APP_CMD); } /*--------CMD55------------------------------------------------------------------------*/ SDIO_CmdInitStructure.SDIO_Argument = 0x00; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_APP_CMD); /***下面是循环发送CMD55+acmd41********************************************************/ 求大神指点,cmd8发送之后如果返回不是SD_OK为什么要发送cmd55,返回正确也要发送CMD55,我看协议说CMD55是为了表征下一个命令是ACMD,但是循环开始后也发送CMD55+ACMD。。这里的有什么用,求指点 |
|
|
|
|
|
|
|
你正在撰写讨论
如果你是对讨论或其他讨论精选点评或询问,请使用“评论”功能。
198 浏览 0 评论
使用stm32l451片子,对ad7606进行3通道100k采样值跳动问题?
1274 浏览 1 评论
STM32进行DMA数据转运,为什么只有A组最后一位数据被转运到B组去?
1725 浏览 2 评论
2026 浏览 3 评论
1615 浏览 0 评论
/6
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-31 06:11 , Processed in 0.741314 second(s), Total 75, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191


淘帖
29618