pic 16f877A this code not working

Thread Starter

damilarem

Joined Aug 5, 2017
41
help on this


sbit LCD_RS at RE0_bit;
sbit LCD_EN at RE2_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISE2_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Hello World"); // Write text'Hello World' in first row
}
 

jayanthd

Joined Jul 4, 2015
945
help on this


sbit LCD_RS at RE0_bit;
sbit LCD_EN at RE2_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISE2_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Hello World"); // Write text'Hello World' in first row
}

while(1); is missing. PIC will restart repeateadly. You will see a blank LCD.

Add while(1); loop at the end of the code before closing the main() loop.
 

hexreader

Joined Apr 16, 2011
581
while(1); is missing. PIC will restart repeateadly. You will see a blank LCD.

Add while(1); loop at the end of the code before closing the main() loop.
Op is using mikroC, where end loop is added automatically. Does no harm to put a while(1) loop, but not actually necessary for this compiler
 

jayanthd

Joined Jul 4, 2015
945
Op is using mikroC, where end loop is added automatically. Does no harm to put a while(1) loop, but not actually necessary for this compiler
Which version of mikroC PRO PIC adds while(1); loop automatically. I have been using mikroC Compilers since 5 years and when I omit the while(1) loop the device resets after reaching the end of main() function.
 

hexreader

Joined Apr 16, 2011
581
I have believed it to be the case for the 7 years that I have been using microC, but I must admit that I always include while(1) just for portability. Not many programs end anyway.

Looks like some testing is needed to prove it one way or the other, but I am away from my PIC gear for a few days, so it will have to wait.

EDIT: - did try compile of very simple program and found a goto $+0 statement at the end of the listing, which seems to support my theory I think.

_main:
;junk.c,2 :: void main() {
;junk.c,3 :: CMCON = 0x07;
0x0016 0x3007 MOVLW 7
0x0017 0x1683 BSF STATUS, 5
0x0018 0x1303 BCF STATUS, 6
0x0019 0x009C MOVWF CMCON
;junk.c,4 :: TRISB = 0x00;
0x001A 0x0186 CLRF TRISB
;junk.c,5 :: PORTB = 0x55;
0x001B 0x3055 MOVLW 85
0x001C 0x1283 BCF STATUS, 5
0x001D 0x0086 MOVWF PORTB
;junk.c,7 :: }
L_end_main:
0x001E 0x281E GOTO $+0
; end of _main
 
Last edited:

Thread Starter

damilarem

Joined Aug 5, 2017
41
help on this


sbit LCD_RS at RE0_bit;
sbit LCD_EN at RE2_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISE2_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Hello World"); // Write text'Hello World' in first row
}
i have tried it still not working but i used pic16f877A and i used the port E for the LCD in which is an AD.. so any help to turn the AD off so i can used for my LCD
 

jayanthd

Joined Jul 4, 2015
945
i have tried it still not working but i used pic16f877A and i used the port E for the LCD in which is an AD.. so any help to turn the AD off so i can used for my LCD
For PIC16F877A to turn off the Analog functions on all pins you have to set

Code:
ADCON1 = 0x8F;
Also you need before

Code:
LCD_Init();
these

Code:
TRIAD = 0x00;
TRISE = 0x00;
@hexreader

I don't code in asm. I have used C code and it resets the PIC. I will make video of hardware (EasyPIC v7) resetting the PIC when while(1); loop is absent. I will update the thread after I make the video and upload it.
 

Thread Starter

damilarem

Joined Aug 5, 2017
41
For PIC16F877A to turn off the Analog functions on all pins you have to set

Code:
ADCON1 = 0x8F;
Also you need before

Code:
LCD_Init();
these

Code:
TRIAD = 0x00;
TRISE = 0x00;
@hexreader

I don't code in asm. I have used C code and it resets the PIC. I will make video of hardware (EasyPIC v7) resetting the PIC when while(1); loop is absent. I will update the thread after I make the video and upload it.
THANKS JAYANTHD I AV TRIED D CODE AND IT WORKS



CAN YOU HELP ME WITH USING LOADCELL AND PIC?
 

jayanthd

Joined Jul 4, 2015
945
To write code I want to know what is the max mV your Load Cell gives and what is the max gms or Kgs your Load Cell measures. I will then write a code for you using PIC16F877A with 4 MHz Crystal.

Open a new thread regarding your weighing scale requirement. I will continue the weighing scale conversation there.
 
Last edited:

hexreader

Joined Apr 16, 2011
581
@ damilarem

Sorry for taking your thread off-track a little. Hopefully the discussion is of interest just the same.

@jayanthd

My code was in mikroC, which produced a listing file after compilation.

Attached is a project folder which I believe proves my theory to be the correct one....

Thank you for all of the help that you give to others :)
 

Attachments

jayanthd

Joined Jul 4, 2015
945
@ damilarem

Sorry for taking your thread off-track a little. Hopefully the discussion is of interest just the same.

@jayanthd

My code was in mikroC, which produced a listing file after compilation.

Attached is a project folder which I believe proves my theory to be the correct one....

Thank you for all of the help that you give to others :)
@hexreader

Ok. I will test your project on easypic v7 and update the thread.
 

Thread Starter

damilarem

Joined Aug 5, 2017
41
is not shouting is just to make u know that what u assked me to do have been done... the name of the thread is "weight scale requirement" thanks
 

jayanthd

Joined Jul 4, 2015
945
is not shouting is just to make u know that what u assked me to do have been done... the name of the thread is "weight scale requirement" thanks
If you type in all caps then it means you are shouting.

I could not find the thread "weight scale requirement".
 

Thread Starter

damilarem

Joined Aug 5, 2017
41
If you type in all caps then it means you are shouting.

I could not find the thread "weight scale requirement".
never knew the caps meant someting like that sorry... i just coppy and paste this from the thread i made a mistake ... this is the name "
weighing scale requirement"
 

jayanthd

Joined Jul 4, 2015
945
never knew the caps meant someting like that sorry... i just coppy and paste this from the thread i made a mistake ... this is the name "
weighing scale requirement"
Why don't you provide the link for the "Weighing Scale requirement" thread instead of providing the thread name ?
 
Top