這是主函數。。。。。無法顯示。。
但是把while循環里的語句屏蔽了,能顯示,但無法實現稱重
請教高手 怎么破
- /***********************************************************
- 程序功能:在12864液晶上顯示一屏漢字
- -----------------------------------------------------------
- ----------------------------------------------------
- 測試說明:觀察液晶顯示
- ***********************************************************/
- #include "msp430.h"
- #include "cry12864.h"
- #include "cry12864.C"
- #include "hx711_1.c"
- #include "hx711.h"
- const uchar hang1[] = {"16位AD值:"};
- unsigned long int count1;
- uchar str1[6]="000000";
- int i;
- void int2str( int ,uchar *);
- void int2str( int x,uchar * str)
- {
- int i=1;
- int temp=10;
- while(x/temp!=0)
- {
- i++;
- temp*=10;
- }
- temp=x;
- str[i]=' ';
- while(i>1)
- {
- str[--i]='0'+(temp%10);
- temp/=10;
- }
- str[0]=temp+'0';
- }
- long int HX711_AVR(){
- count1=0;
- long int tempmax,tempmin;
- long int sum[10];
- for(i=0;i<10;i++)
- {
- sum[i]=HX711_Read();
- if(i==0)
- {
- tempmax=sum[0];
- tempmin=sum[0];
- }
- if(i>0)
- {
- if(sum[i]>tempmax) tempmax=sum[i];
- if(sum[i]<tempmin) tempmin=sum[i];
- }
- }
- for(i=0;i<10;i++)
- {
- if(!(sum[i]==tempmax||sum[i]==tempmin))
- {
- count1=count1+sum[i];
- }
- }
- return (count1/8);
- }
- /***************************主函數*************************/
- void main( void )
- {
- /*下面六行程序關閉所有的IO口*/
- P1DIR = 0XFF;P1OUT = 0XFF;
- P2DIR = 0XFF;P2OUT = 0XFF;
- P3DIR = 0XFF;P3OUT = 0XFF;
- P4DIR = 0XFF;P4OUT = 0XFF;
- P5DIR = 0XFF;P5OUT = 0XFF;
- P6DIR = 0XFF;P6OUT = 0XFF;
- WDTCTL = WDTPW + WDTHOLD; //關狗
- P6DIR |= BIT2;P6OUT |= BIT2; //關閉電平轉換
- Ini_Lcd(); //初始化液晶
- PORT_Init(); //初始AD的SAK,SDT
- Disp_HZ(0x80,hang1,4); //顯示第一行
- while(1)
- {
- int count=HX711_AVR()/256; //獲取AD平均值
- int2str(count,str1); //數字轉換字符串
- Disp_HZ(0x98,str1,3);
- count=0;
- }
- LPM4;
- }
復制代碼 |