換了一顆PIC之後順遂多啦!
原來FVR功能就只是拿來當參考電壓,之前搞得太複雜了
網路狀態會影響MPLAB X 3.40開啟的失敗
uint16_t ADCResult,TM;
uint8_t adhundreds, adtens, adones, adoneth, adtenth;
double VTao;
typedef unsigned char uint8_t;
void USART_putstring(char* StringPtr){
while(*StringPtr != 0x00){
EUSART_Write(*StringPtr);
StringPtr++;}
}
void get_temperature()
{
char charADC[8];
ADCResult = 0x0000;
ADCResult = ADC_GetConversion(channel_AN4);
ADCResult &= 0x0FFF;
// sprintf(charADC,"%u",ADCResult);
// USART_putstring("ADCResult AN4 = ");
// USART_putstring(charADC);
// USART_putstring("\r\n");
VTao = ADCResult*0.5;
// sprintf(charADC,"%d",VTao);
// USART_putstring("VTao = ");
// USART_putstring(charADC);
// USART_putstring("\r\n");
TM=211048.6 - ( 192.1 * VTao);
adtens = TM/10000;
adtens = adtens%10;
adones = TM/1000;
adones = adones%10;
adoneth = TM/100;
adoneth = adoneth%10;
adtenth = TM/10;
adtenth = adtenth%10;
adhundreds = TM;
adhundreds = adhundreds%10;
sprintf(charADC,"%d%d.%d%d%d",adtens,adones,adoneth,adtenth,adhundreds);
USART_putstring(charADC);
// USART_putstring("\r\n");
}
/*
Main application
*/
void main(void) {
SYSTEM_Initialize();
while (1) {
get_temperature();
__delay_ms(500);
}
}
搞定了硬體方面,現在要開始搞App囉
沒有留言:
張貼留言