Skip to main content
Understood an important issue with LVP
Source Link

MaybeThese pics can be programmed in low voltage mode or high voltage mode. You have chosen low voltage with #pragma config LVP = ON

In this mode, pin RB4 is not a programmable I/O and becomes a program mode select input. As it's not connected, the PIC might be in program mode - Unless you have a good reason, always use high voltage programming...... so

#pragma config LVP = OFF

Also, int minimum_step_count = 3; should probably be 4

Also maybe the higher bits set in port aA are set. Try just looking at 2 bits

if((PORTA & 3) == 1) if((PORTA & 3) == 1) ...

And if((PORTA & 3) == 2) ...

if((PORTA & 3) == 2)or better

while((PORTA & 3) == 1) ...

while((PORTA & 3) == 2) ...

Maybe higher bits set in port a. Try

if((PORTA & 3) == 1)

And

if((PORTA & 3) == 2)

These pics can be programmed in low voltage mode or high voltage mode. You have chosen low voltage with #pragma config LVP = ON

In this mode, pin RB4 is not a programmable I/O and becomes a program mode select input. As it's not connected, the PIC might be in program mode - Unless you have a good reason, always use high voltage programming...... so

#pragma config LVP = OFF

Also, int minimum_step_count = 3; should probably be 4

Also maybe the higher bits set in port A are set. Try just looking at 2 bits

if((PORTA & 3) == 1) ...

if((PORTA & 3) == 2) ...

or better

while((PORTA & 3) == 1) ...

while((PORTA & 3) == 2) ...

Source Link

Maybe higher bits set in port a. Try

if((PORTA & 3) == 1)

And

if((PORTA & 3) == 2)