• 大小: 5.45KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-03-27
  • 语言: 其他
  • 标签: 其他  

资源简介


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);  

评论

共有 条评论