DIY Electronic projects
PIC16f877A voltmetar C kod. - Printable Version

+- DIY Electronic projects (https://forum.yu3ma.net)
+-- Forum: Mikrokontroleri (https://forum.yu3ma.net/forum-52.html)
+--- Forum: Microchip PIC (https://forum.yu3ma.net/forum-53.html)
+--- Thread: PIC16f877A voltmetar C kod. (/thread-2554.html)



PIC16f877A voltmetar C kod. - MILANNN - 03-20-2021

Pozdrav.Probao sam od ovog pisanog koda da uradim HEX u         MPLAB X IDE v2.35    ali mi u skoro svim redovima koda pojavi gresku tj. pored skoro svakog rede sa leve strane je crveni kruzic sa znakom " ! "
Pisao sam za arduino ali nisam nikad za PIC pa me intresuje da li je ovaj kod ispravan a ja nesto gresim u MPLABu
jer skinuo sam ga sa interneta.Evo kako je ceo kod napisan:
Ovde gde su crtice u nastavku reda nema kruzica sa znakom '!" dok u svim ostalim ima.

Code:
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
int Adread;             ------------------------
float voltage;          ------------------------
char volt[4];           ------------------------
void main() {           ------------------------

PORTA = 0;
TRISA = 0X01;
PORTB = 0;
TRISB = 0;
LCD_Init();
ADC_Init();
LCD_Cmd(_LCD_CURSOR_OFF);
LCD_Cmd(_LCD_CLEAR);
LCD_Out(1, 1, "Digital voltmeter");
delay_ms(1000);
while (1)                     --------------------------
{
voltage = ADC_Read(0);
voltage = (voltage * 5 * 10)/ (1024);           -----------------------
inttostr(voltage,volt); // it converts integer value into string
Lcd_Out(2,1,"Voltage = ");
Lcd_Out(2,11,Ltrim(volt));
Lcd_Out(2,13,"Volt");
}
}



RE: PIC16f877A voltmetar C kod. - enaB - 03-20-2021

To je kod za mikroC kompajler, nadji drugi


RE: PIC16f877A voltmetar C kod. - ZASto - 03-21-2021

Uz malo prepravki možeš da izkompajliraš u PBP, koji inače koristiš.


RE: PIC16f877A voltmetar C kod. - MILANNN - 03-21-2021

Hteo sam da da bude pisam u C , za PBP nije problem.