|
我想用串口显示出G2553内部温度的值,但在编译的时候出现了莫名的错误,对这个错误...
[复制链接]
本帖最后由 易爆炸弹 于 2015-8-16 15:18 编辑
我想用串口显示出G2553内部温度的值,但在编译的时候出现了莫名的错误,请问一下哪错了啊?
#68 expected a "}" msp430g2xx3_usci_uart_9600.c(这是编译的错误)
#include
#include
#include
#include "msp430g2553.h"
/*
* ======== Grace related declaration ========
*/
extern void CSL_init(void);
char mystring[50] = "300 my test program!\r\n";
void ADC10_init(void);
void myputs(char * string);
/*
* ======== delay ========
*/
void delay(unsigned int time_delay)
{
unsigned int i,j,k,a;
for(i = 0; i < time_delay; i++)
{
for(j = 0; j < 20; j++)
{
for(k = 0; k < 20; k++)
{
for(a = 0; a < 20; a++)
__delay_cycles(8);
}
}
}
}
/*
* ======== main ========
*/
int main(void)
{
int result;
int temp;
int IntDeg;
CSL_init();
ADC10_init();
myputs(mystring);
myputs("msp430 startup!erererer\r\n");
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
while(1)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
// _bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
__delay_cycles(1000);
//-----ADC转换完成中断唤醒CPU后才执行以下代码-----
temp = ADC10MEM; //读取AD采样值
IntDeg= temp*4225/1024 - 2777; //转换为摄氏度,并10倍处理
while(1)
{
ADC10CTL0 |= ENC+ADC10SC;
while((ADC10CTL0&ADC10IFG)==0);
//result = ADC10MEM;
IntDeg=(unsigned int)((result-746)/(0.24069)+286);//P64 in the book
mystring[0] = (IntDeg/1000) + '0';
mystring[1] = ((IntDeg%1000)/100) + '0';
mystring[2] = ((IntDeg%100)/10) +'0';
mystring[3] = (IntDeg%10) + '0';
myputs(mystring);
delay(50);
}
}
/*
* ======== string output ========
*/
void myputs(char * string)
{
unsigned char num;
for( num = 0; num < strlen(string); num++ )
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = string[num]; // TX -> RXed character
}
}
void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}
void ADC10_init(void)
{
ADC10CTL0 &= ~ENC;
ADC10CTL0 = ADC10IE + ADC10ON + REFON + ADC10SHT_3 + SREF_1;
ADC10CTL1 = CONSEQ_0 + ADC10SSEL_0 + ADC10DIV_3 + SHS_0 + INCH_10;
__delay_cycles(30000);
ADC10CTL0 |= ENC;
}
/******************************************************************************************************
* 名 称:ADC10_ISR_HOOK
* 功 能:ADC转换完成后唤醒CPU
* 入口参数:无
* 出口参数:无
* 说 明:直接从CCS的Example中移植过来
* 范 例:无
******************************************************************************************************/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR_HOOK(void)
{
_bic_SR_register_on_exit(LPM4_bits);
}
|
|