• AVR Freaks

Hot!Memory problem PIC16F

New Member
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2017/03/27 08:15:33
  • Location: 0
  • Status: offline
2020/09/19 07:26:12 (permalink)

Memory problem PIC16F

Hi !
I'm trying to understand a problem with the memory of my PIC16F877A (yes I know it's old).
I have a robot with 4 wheels controlled via Bluetooth (module HC05).
When I excite the motors in opposite directions, abrupt change of direction, I have the program that starts to do anything.
I looked at what happens in debug mode and I see that the PIC is in an area of the memory where there is no more program.
Only the interrupt timer continues to run.
I added a Watchdog and I can see that the PIC reset.
But sometimes it doesn't go out of the program. I have at the beginning of my program a calculation that initializes coefficients from constants that I define at compile time (for example the speed of the motors). This function is executed only once but when I excite the motors, my coefficients change value!
So to resule, when a sudden change of direction occurs, either the program goes out of its memory area, or some variables have changed and modify the behavior of my robot.
I made a test by modifying the maximum speed of my robot and when it is not too fast, no problem appears. So I'm looking at a problem with the motors' current calls (I activated the brown-out).
Do you know by experience how much it can corrupt a program? Can a small voltage drop cause memory problems or do I have to focus on the program?
I'm using MPLAB 5.15 and XC8 1.34.
Thank you for your help!

2 Replies Related Threads

    Murton Pike Systems
    Senior Member
    • Total Posts : 48
    • Reward points : 0
    • Joined: 2020/09/10 02:13:01
    • Location: 0
    • Status: offline
    Re: Memory problem PIC16F 2020/09/19 13:52:18 (permalink)
    +2 (2)
    Classic noise problem.
    Noise is upsetting the PIC and causing it to do odd things.
    Sort out power supply, grounding and decoupling.
    Super Member
    • Total Posts : 681
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: Memory problem PIC16F 2020/09/19 15:53:12 (permalink)
    +1 (1)
    Start with this:
    Jump to:
    © 2020 APG vNext Commercial Version 4.5