c语言程序无法正常运行怎么办,一条语句让程序无法正常运行求解

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

// Description: This example shows how to perform repeated conversions on a// single channel using "repeat-single-channel" mode. AVcc is used for the// reference and repeated conversions are performed on Channel A0. Each// conversion result is moved to an 8-element array called results[]. Test by// applying a voltage to channel A0, then running. To view the conversion results// open a watch window and view 'results.'// This can run even in LPM4 mode as ADC has its own clock

#include "io430.h"

#include "in430.h"

#include "type.h"

#include "nbc430.h"

#include "lcd1602.h"

#define Num_of_Results 8

static U16 result[Num_of_Results];

float voltage;

//************************************IO_init(void)

void IO_init(void)

{

P6SEL |= 0X01; // Enable P6.0 channel A0

}

//************************************ADC12_init(void)

void ADC12_init(void)

{ ADC12CTL0 = ADC12ON + MSC + SHT0_15;

ADC12CTL1 = SHP + CONSEQ_2;

ADC12IE = 0X01; // Enable ADC12FIG.0

ADC12CTL0 |= ENC; // Enable conversions}

//*************************************ADC12_count(void)

float ADC12_count(U16 temp)

{ voltage = (float)temp / 4095 * 3.3;

return voltage;

}

//************************************main(void)

int main( void )

{ // Stop watchdog timer to prevent time out reset

WDTCTL = WDTPW + WDTHOLD;

IO_init();

LCD_Init();

ADC12_init();

LCD_Print_String(0,0,"HELLO MAZIRONG");

while(1) {

ADC12CTL0 |= ADC12SC; // Start conversion

LCD_Print_Char(0,1,(int)ADC12_count(result[0])%10 + 0X30);

LCD_Print_Char(1,1,'.');

LCD_Print_Char(2,1,(int)(ADC12_count(result[0])*10)%10 + 0X30);

LCD_Print_Char(3,1,(int)(ADC12_count(result[0])*100)%10 + 0X30);

LCD_Print_Char(4,1,(int)(ADC12_count(result[0])*1000)%10 + 0X30);

_BIS_SR(LPM0_bits + GIE);

}

}

//******************************ADC12 interrupt services rontine

#pragma vector = ADC12_VECTOR__interrupt void ADC12_ISR(void)

{ static U8 index = 0;

result[index] = ADC12MEM0;

/*index++;

if(index == 8)

{

index = 0;

}*/

index = (index + 1) % 8; // (这句话和上面的三个语句理论上功效一样,但用了这句程序就跑飞了(while(1)中的语句只能执行一次然后程序就不能进入while(1)执行了用仿真试过)(?)

_BIC_SR_IRQ(LPM0_bits);}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值