資源簡介
STM32讀12位絕對式編碼器,本代碼的測試儀器為歐姆龍。
代碼片段和文件信息
#include?“stm32f10x.h“
#include?“stm32f10x_usart.h“
#include?
#include?
#include?
#define?CMD_BUFFER_LEN?100
GPIO_InitTypeDef?GPIO_InitStructure;
void?Delay(__IO?uint32_t?nCount)
{
??for(;?nCount?!=?0;?nCount--);
}
void?RCC_Config(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA?ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC?ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1?ENABLE);
}
void?GPIO_Config(void)
{
//串口 ?PA9?PA10
GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_9;???????????????????????//管腳9?
GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;?????//復用推挽輸出?
GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
GPIO_Init(GPIOA?&GPIO_InitStructure);?????????????????????????????//TX初始化?
GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_10;?????????????????????//管腳10?
GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;?//浮空輸入?
GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
GPIO_Init(GPIOA?&GPIO_InitStructure);??
- 上一篇:三星研究院上機題目數據及源碼
- 下一篇:MR25H256 驅動程序 源文件
評論
共有 條評論