完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我在我的伏特表的最后一关遇到了一些麻烦。我的代码:它出现了错误:VoltMeter。C:168:警告:(361)函数声明了代码的这一部分:我正在努力寻找解决这个问题的方法。感谢您的任何帮助。
以上来自于百度翻译 以下为原文 Hi, i am having some trouble with the final hurdle of my volt meter. My code: //Volt Meter Program //Made for PIC 18F4525 //11/11/16 //Christopher 'Galviniser' Galvin // PIC18F4525 Configuration Bit Settings // 'C' source line config statements #include // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. // CONFIG1H #pragma config OSC = INTIO67 // Oscillator Selection bits (Internal oscillator block, port function on RA6 and RA7) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled) #pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled) // CONFIG2L #pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = SBORDIS // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled)) #pragma config BORV = 3 // Brown Out Reset Voltage bits (Minimum setting) // CONFIG2H #pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit)) #pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768) // CONFIG3H #pragma config CCP2MX = PORTC // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1) #pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset) #pragma config LPT1OSC = OFF // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation) #pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled) // CONFIG4L #pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset) #pragma config LVP = OFF // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled) #pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode)) // CONFIG5L #pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-003FFFh) not code-protected) #pragma config CP1 = OFF // Code Protection bit (Block 1 (004000-007FFFh) not code-protected) #pragma config CP2 = OFF // Code Protection bit (Block 2 (008000-00BFFFh) not code-protected) // CONFIG5H #pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected) #pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM not code-protected) // CONFIG6L #pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-003FFFh) not write-protected) #pragma config WRT1 = OFF // Write Protection bit (Block 1 (004000-007FFFh) not write-protected) #pragma config WRT2 = OFF // Write Protection bit (Block 2 (008000-00BFFFh) not write-protected) // CONFIG6H #pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected) #pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected) #pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write-protected) // CONFIG7L #pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks) #pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks) #pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks) // CONFIG7H #pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks) //Definitions// #define EnablePin LATBbits.LATB0 #define RSPin LATBbits.LATB1 #define RWPin LATBbits.LATB2 #define TwoLinesEightBit 0b00111100 #define IncPosition 0b00000110 #define CursorNoBlink 0b00001100 #define ClearScreen 0b00000001 #define ReturnHome 0b00000010 #define LineTwo 0b11000000 #define DoBlink 0b00001111 #define ShiftLeft 0b00010000 #define ShiftRight 0b00010100 //Global Variables// unsigned char ClockCount; char str[10]; //Array 80 locations float FloatingVariable; //Sub-Program// void Initialise () { TRISA = 0xFF; //Inputs (One A/D converter) TRISB = 0x00; //Outputs TRISC = 0x00; //LCD outputs ADCON0 = 0b00000011; //Channel '0' Pin RA0 (AN0) ADCON1 = 0b000010; //All analogue inputs ADCON2 = 0b00111111; T0CON = 0b11000001; //8-bit, 1:4 prescale OSCTUNE = 0b00000000; //31KHz OSCCON = 0b01111100; //8MHz, Stable, Primary oscillator } void Delay (unsigned char t) //The ClockCount can be set inside the subroutine, the delay value can be placed for '' at 0.5 ms { t *= t*2; ClockCount = t; Loop:TMR0 = 0; //Set timer to 0 INTCONbits.TMR0IF = 0; //Set timer interrupt bit to 0 while (INTCONbits.TMR0IF == 0) continue; ClockCount --; //Take one off the count if (ClockCount == 0) return; else goto Loop; } void LCDData (unsigned char n) { LATC = n; EnablePin = 1; EnablePin = 0; Delay (2); } void LCDInit () { Delay (45); RSPin = 0; //Tell LCD data being sent is instructions RWPin = 0; //Tell the LCD we are writing to LCD LCDData (TwoLinesEightBit); LCDData (CursorNoBlink); LCDData (IncPosition); LCDData (ClearScreen); LCDData (ReturnHome); RSPin = 1; //Transfer all data to LCD } void LCDString (const char *word) { while (*word) { LCDData(*word); *word ++; } } /*int String () { sprintf(str, "%.2f", FloatingVariable); }*/ /*int ReadADC (int ch) { ((ADRESH <<8) + ADRESL) }*/ //Main Program// void main () { Initialise (); LCDInit (); LCDString ("Voltmeter"); Delay (2000); RSPin = 0; LCDData (ClearScreen); RSPin = 1; while (1) { ADCON0bits.GO_nDONE = 1; while (ADCON0bits.GO_nDONE == 0) continue; FloatingVariable = (((ADRESH << 8) + ADRESL)*0.00488); sprintf(str, "%.2f", FloatingVariable); LCDString (str); LCDString ("v"); } } It is coming up with error: VoltMeter.c:168: warning: (361) function declared implicit int for this part of the code: sprintf(str, "%.2f", FloatingVariable);And im struggling to find how to resolve this. Any help would be appreciated Thankyou |
|
相关推荐
2个回答
|
|
|
您可能需要包括STDIO .H和/或STDLIB h。
以上来自于百度翻译 以下为原文 You may need to include stdio.h and/or stdlib.h |
|
|
|
|
|
第一个包括文件工作,第二个不包括文件。谢谢你的帮助。我现在可以继续了。
以上来自于百度翻译 以下为原文 The first include file works, the second does not. Thank-you for your help. I am able to continue now. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5795 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1126浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 13:17 , Processed in 0.816152 second(s), Total 77, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
6723