lm2018yy 发表于 2018-6-13 15:14:27

stm32 systick

本帖最后由 lm2018yy 于 2018-6-14 11:12 编辑

使用stm32f103zet6芯片
void delay_us(uint32_t n)
{   
      SysTick->LOAD=72*n;      //72M,
      SysTick->CTRL=0x00000005;//HCLK(72M)
      while(!(SysTick->CTRL&0x00010000)); //0   
      SysTick->CTRL=0x00000004;
}
main函数中
             while(1)
                {
                        GPIO_SetBits(GPIOF, GPIO_Pin_All);
                        delay_us(2000);
                        

                        GPIO_ResetBits(GPIOF, GPIO_Pin_All);
                        delay_us(1000);
                }

管脚测试产生如0032波形:



求大神为啥是这样?不应该是“1”长“0”短吗?



RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOF |
                         RCC_APB2Periph_GPIOC, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOF, &GPIO_InitStructure);


while(1)
{
   GPIO_SetBits(GPIOF, GPIO_Pin_All);
   //GPIO_Write(GPIOF, 0xffff);
   //delay_us(20000);
   n=20000;while(n){n--;}
   GPIO_Write(GPIOF, 0x0);//GPIO_ResetBits(GPIOF, GPIO_Pin_All);
   //delay_us(10000);
   n=10000;while(n){n--;}
}

GPIO配置没变,换为此段程序,正常。
图如004:

发表于 2018-6-13 15:36:35

楼主是直连CPU引脚直接测试的吗?最好有结合电路图和实际的使用进行分析。

lm2018yy 发表于 2018-6-13 15:41:14

安 发表于 2018-6-13 15:36
楼主是直连CPU引脚直接测试的吗?最好有结合电路图和实际的使用进行分析。 ...

管脚直接测试,不知啥问题导致的

发表于 2018-6-13 15:46:39

单独测试一下,拉高,或者拉低,检测到的波形是什么样的。

电子星辰 发表于 2018-6-13 16:07:36

1.GPIO_SetBits函数里是输出高电平?
2.所测引脚接没接上拉电阻?

baitiandesinian 发表于 2018-6-13 16:08:40

谢谢分享:):):)

lm2018yy 发表于 2018-6-13 16:38:08

安 发表于 2018-6-13 15:46
单独测试一下,拉高,或者拉低,检测到的波形是什么样的。

单步调试,管脚输出正常

wenyangzeng 发表于 2018-6-13 17:20:04

本帖最后由 wenyangzeng 于 2018-6-13 20:01 编辑

特地找快F1板子试一下,完全正常,看楼主的波形图,那个高电平的幅度是否达到3V?貌似GPIOF未配置正确:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF, &GPIO_InitStructure);







andeyqi 发表于 2018-6-14 07:05:32

楼主的电路是否有反向电路,测量的是CPU的引脚吗,是不是测量点选择的有问题,感觉理论上应该没问题,如果测量的位置没问题,建议检查下电路。

wudianjun2001 发表于 2018-6-14 08:31:37

是否有外部电路,软件管脚配置是否正确?
页: [1] 2
查看完整版本: stm32 systick