初级会员

- 积分
- 65
- 金钱
- 65
- 注册时间
- 2016-3-31
- 在线时间
- 19 小时
|
1金钱
[mw_shl_code=applescript,true]#include "led.h"
#include "delay.h"
#include "sys.h"
#include "key.h"
#include "usart.h"
#include "iwdg.h"
#include "exti.h"
#include "timer.h"
#include "pwm.h"
#include "rtc.h"
#include "lkit.h"
extern u8 TIM2CH1_CAPTURE_STA;
extern u16 TIM2CH1_CAPTURE_VAL;
volatile u8 key_tag_t=0;
int main(void)
{
volatile u8 tab=0;
u16 watcher=400;
u8 tag_delay=0;
u32 temp=0;
NVIC_Configuration();
delay_init();
delay_ms(10);
//uart_init(9600);
TIM1_PWM_Init(899,0);
////above this row is the initialiation block
while(1)
{
if (1)
{
if (watcher>901) watcher=0;
else watcher+=100;
TIM_SetCompare1(TIM1,watcher);
//printf("\r\n get!");
delay_ms(1000);
}
}
}
}[/mw_shl_code]
如上所述,各个头文件都是原子本来的文件,单独运行没有问题。
那么问题来了:
当我在代码中 用了 uart_init(9600); 这行的时候,PWM失效了!
而当我把这行代码注释掉以后,LED又可以进行亮度变换了。
其中,uart_init(9600)中用的是PA9 PA10作为TX RX,也就是和原子哥的代码完全一样的。
PWM用的是TIM1_CH1,也就是PA8。
所以我想问:对PA9 PA10进行usart的配置,会影响到PA8的PWM配置吗?
研究了一下午,硬是不知道为什么,跪求帮助!!!
|
|