初级会员

- 积分
- 116
- 金钱
- 116
- 注册时间
- 2017-7-3
- 在线时间
- 30 小时
|
10金钱
//主函数大概是#include "stm32f10x.h"
#include "usart.h"
#include <stdio.h>
__IO u8 Flag_KEY;
int main(void)
{
Usart_Init(4800);
SysTick_Config(SystemCoreClock/1000);
while (1)
{
printf("\r\nI am in while loop\r\n");
if (Flag_KEY)
{
printf("\r\nI am in the if loop\r\n");
Flag_KEY = 0;
}
}
//中断处理函数
extern __IO u8 Flag_KEY;
void SysTick_Handler(void)
{
static __IO u8 Flag_KEY_temp;
printf("\r\nI am in IRQ\r\n");
if(++Flag_KEY_temp >= 40)
{
Flag_KEY_temp = 0;
Flag_KEY = 1;
printf("\r\nFlag key = 1\r\n");
}
}
下载到板子里值打开串口 只接收到I am in IRQ, Flag key =1, 求帮我看下在哪里出了问题
|
最佳答案
查看完整内容[请看2#楼]
弄好了 原因好像是SysTick_Handler与Printf相性不大好
要用printf的话 把if(++Flag_KEY_temp >= 40) 这里改大点 例如改成if(++Flag_KEY_temp >= 400)
或者直接不在SysTick_Handler里用Printf函数
|