FAQ
TL;DR: On PIC16F177x, 60% of tested parts assembled MOVLB incorrectly in MPASM v3.15; “Microchip appear to have really messed up.” Update to MPLAB X v3.65 or replace MOVLB with MOVLW/MOVWF BSR. [Elektroda, Anonymous, post #21679510]
Why it matters: If your PIC16F1779 "programs fine but does nothing," this pinpoints the toolchain bug and the fix, fast.
Quick-Facts
- MPASM in MPLAB X v3.15 produced wrong MOVLB opcodes on PIC16F1777/78/79; v3.65 fixed it. [Elektroda, Anonymous, post #21679511]
- Temporary workaround: use movlw bank ; movwf BSR instead of movlb bank. Effective but not scalable for large libraries. [Elektroda, Anonymous, post #21679509]
- Typical symptom set: compile/verify OK, I/O pins stay Hi‑Z, OSCCON stuck at 500 kHz (POR). [Elektroda, Anonymous, post #21679500]
- ANSEL defaults to analog; clear ANSELx to enable GPIO behavior, input or output. [Elektroda, Anonymous, post #21679506]
- Good setup notes: connect both VDD and both VSS pins, keep ICSP leads short, ensure solid target power. [Elektroda, Anonymous, post #21679497]
Quick Facts
- MPASM in MPLAB X v3.15 produced wrong MOVLB opcodes on PIC16F1777/78/79; v3.65 fixed it. [Elektroda, Anonymous, post #21679511]
- Temporary workaround: use movlw bank ; movwf BSR instead of movlb bank. Effective but not scalable for large libraries. [Elektroda, Anonymous, post #21679509]
- Typical symptom set: compile/verify OK, I/O pins stay Hi‑Z, OSCCON stuck at 500 kHz (POR). [Elektroda, Anonymous, post #21679500]
- ANSEL defaults to analog; clear ANSELx to enable GPIO behavior, input or output. [Elektroda, Anonymous, post #21679506]
- Good setup notes: connect both VDD and both VSS pins, keep ICSP leads short, ensure solid target power. [Elektroda, Anonymous, post #21679497]
How do I fix a PIC16F1779 that verifies but then does nothing after programming?
Update your toolchain. MPLAB X v3.65 assembles MOVLB correctly for PIC16F177x and resolved the “runs nothing” symptom in this case. If you cannot update immediately, replace MOVLB with MOVLW/MOVWF BSR as a stopgap. After updating, the original code ran without changes. [Elektroda, Anonymous, post #21679511]
What was the root cause in this thread?
MPASM assembled MOVLB to 0x014n instead of 0x002n, so BSR never changed banks. Writes to TRIS, LAT, ANSEL, and OSCCON targeted the wrong bank, leaving pins Hi‑Z and clocks at defaults. “MOVLB was completely ignored.” [Elektroda, Anonymous, post #21679507]
Which PIC16F177x devices showed the MOVLB opcode issue?
A short build test showed: 16F1773 and 16F1776 correct; 16F1777, 16F1778, and 16F1779 wrong. That is 3 of 5 devices affected. [Elektroda, Anonymous, post #21679510]
What’s a quick workaround if I can’t edit many files?
Replace each MOVLB bank instruction with MOVLW bank followed by MOVWF BSR. It works immediately but is impractical for large codebases or libraries. Use it only to unblock testing. [Elektroda, Anonymous, post #21679509]
How can I confirm whether my code is actually running on-chip?
Use MPLAB X with PICkit 3 to single‑step and watch SFRs. Check BSR while executing MOVLB. If BSR doesn’t change, you’re hitting the assembler bug. Then manually set BSR and observe pins toggling. [Elektroda, Anonymous, post #21679507]
Why are my pins stuck in Hi‑Z or reading analog?
ANSELx defaults to analog on POR. Clear ANSEL registers to enable digital GPIO, then set TRIS/LAT as needed. Without this, outputs won’t drive and inputs read analog. [Elektroda, Anonymous, post #21679506]
Why won’t the internal oscillator change when I write OSCCON?
If MOVLB is wrong, your OSCCON write hits the wrong bank. The device stays at its 500 kHz POR frequency, making it look unresponsive. Fix MOVLB or set BSR correctly. [Elektroda, Anonymous, post #21679500]
Should I disable MCLR or LVP while debugging?
You can disable MCLR in CONFIG if needed. If MCLR is enabled, use a pull‑up. Ensure LVP is off unless you require it. These settings avoided false resets here. [Elektroda, Anonymous, post #21679494]
Could wiring or power cause the "programs but doesn’t run" symptom?
Verify both VDD and both VSS are connected and decoupled. Keep ICSP leads short and stable. If powering from the programmer, raise target V slightly. Poor grounding or long leads can complicate debugging. [Elektroda, Anonymous, post #21679497]
What is MPASM, MOVLB, and BSR in plain English?
MPASM is Microchip’s assembly tool. MOVLB selects a memory bank. BSR is the Bank Select Register that MOVLB should update. If MOVLB encodes wrong, BSR stays unchanged and your SFR writes miss. [Elektroda, Anonymous, post #21679507]
Which MPLAB X versions and OS details mattered here?
MPLAB X v3.15 showed the MPASM error on 16F177x. MPLAB X v3.65 fixed MOVLB. MPLAB X v4.15 didn’t install on the user’s Windows XP, so they stayed on v3.65. [Elektroda, Anonymous, post #21679511]
What is ANSEL and why must I clear it?
ANSEL controls analog mode per pin. On POR, many pins default to analog. Clear relevant ANSELx bits to use pins as digital GPIO. “You do have to turn that ‘off’ to get GPIO functionality.” [Elektroda, Anonymous, post #21679506]
How can I quickly test if any pins are actually toggling?
Declare several pins as outputs and toggle them all. If none move, suspect bank selection or configuration prevents writes from reaching LAT/PORT. This isolated the issue here. [Elektroda, Anonymous, post #21679499]
Can PICkit 3 report a good verify while the MCU still does nothing?
Yes. Programming and verify can pass while the app never leaves POR‑like behavior due to mis‑assembled MOVLB and incorrect banked SFR writes. [Elektroda, Anonymous, post #21679491]
Give me a 3‑step way to diagnose the MOVLB/BSR issue fast.
- Single‑step MOVLB while watching BSR in the debugger.
- If BSR stays unchanged, temporarily write BSR with MOVLW/MOVWF and retest.
- Rebuild with a toolchain that encodes MOVLB correctly. [Elektroda, Anonymous, post #21679507]