+ Post New Thread
Results 1 to 13 of 13
  1. #1
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    MCLR with PIC16F877a software

    Hi members,
    im working on PIC16F877A micro controller with 20Mhz crystal and with xc8 compiler , my problem is the lcd working properly with icd3 connected(i flash the code into micro controller), when i remove icd3 tool and power off/on the main unit lcd not displaying anything, until I touch the MCLR pin to GND point through a wire once / pressing push button switch connected to MCLR , i dont know why? one more thing how to set MCLR in software, i tried #pragma config MCLRE = ON, but is showing error to me, i need help? here are my configuration bits
    [code]
    #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
    #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
    #pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
    #pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR enabled)
    #pragma config LVP = ON // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
    #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
    #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
    #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
    [\ code]
    Last edited by mayasunny; 24th April 2019 at 08:22.

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 2
    Points: 2,573, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    501
    Helped
    46 / 46
    Points
    2,573
    Level
    11

    Re: MCLR with PIC16F877a software

    Change this

    Code:
    #pragma config LVP = ON // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
    to this
    Code:
    #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)



  3. #3
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    Re: MCLR with PIC16F877a software

    yes i changed, but same problem



  4. #4
    Advanced Member level 2
    Points: 2,573, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    501
    Helped
    46 / 46
    Points
    2,573
    Level
    11

    Re: MCLR with PIC16F877a software

    Show your MCLR pin circuit.



  5. #5
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    Re: MCLR with PIC16F877a software

    i don't have its schematics, but R1=10k , R2 =470ohms



    •   AltAdvertisment

        
       

  6. #6
    Super Moderator
    Points: 73,726, Level: 66
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,968
    Helped
    3407 / 3407
    Points
    73,726
    Level
    66

    Re: MCLR with PIC16F877a software

    Hi,

    i don't have its schematics
    Professionals draw schematics. Even hand drawn is good.

    I think it prevents from pitfalls and errors..

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisment

        
       

  7. #7
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    Re: MCLR with PIC16F877a software

    Quote Originally Posted by KlausST View Post
    Hi,


    Professionals draw schematics. Even hand drawn is good.

    I think it prevents from pitfalls and errors..

    Klaus
    dear KlausST, im not familiar with schematics/hardware connections i have EVB board, a push button is connected to MCLR pin(two parallel resistors to Vdd) sorry for my bad knowledge, i don't think so this will help you, any other suggestions



  8. #8
    Super Moderator
    Points: 73,726, Level: 66
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,968
    Helped
    3407 / 3407
    Points
    73,726
    Level
    66

    Re: MCLR with PIC16F877a software

    Hi,

    im not familiar with schematics/hardware connections
    You have to learn it sooner or later. My recommendation: now

    i have EVB board
    Every EVB board should come with a schematic.

    a push button is connected to MCLR pin(two parallel resistors to Vdd)
    ..and here we have the problem: This description makes no sense to me.
    --> Any hand drawn sketch is more informative.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  9. #9
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    Re: MCLR with PIC16F877a software

    can we set MCLR in software,



  10. #10
    Super Moderator
    Points: 78,697, Level: 68
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,887
    Helped
    4303 / 4303
    Points
    78,697
    Level
    68

    Re: MCLR with PIC16F877a software

    can we set MCLR in software,
    Not in the 16F877A. Most modern PICs have an option to internally connect MCLR to VDD so the pin is released for other uses but the venerable 877A is too old for that.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  11. #11
    Member level 2
    Points: 229, Level: 2

    Join Date
    Mar 2019
    Posts
    42
    Helped
    0 / 0
    Points
    229
    Level
    2

    Re: MCLR with PIC16F877a software

    Quote Originally Posted by betwixt View Post
    Not in the 16F877A. Most modern PICs have an option to internally connect MCLR to VDD so the pin is released for other uses but the venerable 877A is too old for that.

    Brian.
    thank you so much betwixt, u cleared my doubt.
    can i use POR(power on Reset) in software like PCONbits.nPOR = 0; or is there any methods for software reset



    •   AltAdvertisment

        
       

  12. #12
    Super Moderator
    Points: 73,726, Level: 66
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,968
    Helped
    3407 / 3407
    Points
    73,726
    Level
    66

    Re: MCLR with PIC16F877a software

    Hi

    you really need to read the datasheet about reset. It contains all information you need to know.

    Software reset is no hardware reset. With many microcontrollers a software reset does not clear all the values that a hardware reset does. It is not equal.
    POR is - like the name says - the PowerOnReset. It will be activated at power ON. Usually there is no chance to do the same with software.
    Often a Watchdog reset is the one hardware Reset that may be controlled with software.
    Whether this applies for your controller is written in the datasheet.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  13. #13
    Super Moderator
    Points: 78,697, Level: 68
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,887
    Helped
    4303 / 4303
    Points
    78,697
    Level
    68

    Re: MCLR with PIC16F877a software

    You can't exactly simulate a hardware reset because the reason for the last reset is held in one of the registers and set at the time it happens.
    The easiest way to force a restart rather than a full reset is to enable the watchdog timer then go into a tight loop so it times out. For example call this routine:

    ForceRestart()
    {
    while();
    }

    Note that it might not work if you reset WDT in an interrupt routine but you shouldn't ever do that anyway!

    You can also force a call to the reset vector, you might have to do this as an assembly language instruction "#asm goto 0".
    Another method that might work, possibly not in early versions of XC8 though, is to use the RESET(); instruction. Note it is in upper case.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--