完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
怎么把这些代码改成MSPF169的版本?改时钟部分也行 #include #include #include #define CPU_F ((double)8000000) #define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0)) #define false 0 #define true 1 //这些变量是全局的,因为它们是在中断服务程序中使用! unsigned int rate[10]; // 数组来保存最后十个IBI值 unsigned int amp = 120; // 用于保存脉冲波形的振幅,发送 unsigned int temp =0 ; //温度 unsigned int BPM=600; // 用于保存脉冲速率 unsigned int IBI = 600; // 持有次之间的时间 unsigned int Peak =512; //初始化 心跳峰值 unsigned int Trough = 512; //用来寻找脉搏波最小值,发送 unsigned int thresh = 512; //初始化 心跳最小值 _Bool Pulse = false; //脉冲波高,真。假时,低 _Bool firstBeat = true; // 用于启动 发送速率数组 _Bool secondBeat = false; // 用于启动 发送速率数组 _Bool QS = false; // 为真时,发现了一拍心跳节拍。 unsigned int Signal; // 持有传入的原始数据 unsigned long sampleCounter = 0; // 当前时间 unsigned long lastBeattime = 0; // 上个心跳时间 unsigned long time; //用于记录时间 // p6.0 a1; // 时钟默认情况 // FLL时钟 FLL选择 XT1 // 辅助时钟 ACLK选择 XT1 32768Hz // 主系统时钟 MCLK选择 DCOCLKDIV 8000000Hz // 子系统时钟 SMCLK选择 DCOCLKDIV 8000000Hz // TA1选择ACLK,最大计数值为32768,中断频率为1HZ void select_xt1(void) { // 启动XT1 P7SEL |= 0x03; UCSCTL6 &= ~(XT1OFF); UCSCTL6 |= XCAP_3; do { UCSCTL7 &= ~XT1LFOFFG; }while (UCSCTL7&XT1LFOFFG); } void dco_config(void) { __bis_SR_register(SCG0); UCSCTL0 = 0x0000; UCSCTL1 = DCORSEL_5; UCSCTL2 = FLLD_1 + 243; __bic_SR_register(SCG0); // 使能FLL功能 __delay_cycles(250000); do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG); SFRIFG1 &= ~OFIFG; }while (SFRIFG1&OFIFG); } void init_clock(void) { WDTCTL = WDTPW + WDTHOLD; // 停止看门狗 select_xt1(); // 选择XT1 dco_config(); } void init_UART(void) { P3SEL = 0x30; // 选择P3.4和P3.5的复用功能 UCA0CTL1 |= UCSWRST; UCA0CTL1 |= UCSSEL__SMCLK; UCA0BR1 = 0X00; UCA0BR0 = 0X45; // UCA0MCTL |= UCBRS_3 + UCBRF_0; // UCA0CTL1 &= ~UCSWRST; // UCA0IE |= UCRXIE; } void init_adc12(void) { P6SEL = 0x01; ADC12CTL0 &=~ ADC12ENC; ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_0; ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1+ADC12SSEL1 ; ADC12MCTL0 |= ADC12INCH_0+ADC12MSC; ADC12IE = 0x03; ADC12CTL0 |= ADC12ENC; } void init_TA1() { TA1CCTL0 = CCIE; TA1CCR0 =16000; TA1CTL = TASSEL_2 + MC_1 + TACLR; } int U0putchar(int ch) { UCA0TXBUF = ch; while(!(UCA0IFG & UCTXIFG)); return ch; } void Uart0Sends_p(char *s) { while(*s!=' |