Third day looking at this problem. Need a new set of eyes.
MCU=16F1829 (not LF version)
Language=MPASM
Programmer/Debugger=MPLAB ICD3 using hardware debug
Defined SW1 as RA2
Programmer and same chip worked in demo described here: https://www.electro-tech-online.com/threads/driving-stepper-motor-gauges.144733/page-2#post-1226483
Program hangs here:
Program Counter (PC) goes to "goto Debounce" as if SW1 were low. Voltmeter on SW1 shows 4.95V. When SW1 is pressed, voltmeter goes to zero. Pull-up resistor on SW1 = 22K. Pressing SW1 has no on PC.
I am a bit confused about what the Watch window means:
PORTA does not change regardless of whether SW1 is pressed. Why does "RA2" show 8 bits? As the PC goes "btfss" and "goto debounce" RA2 changes from 0xCA to 0xCB (i.e., bit<0> is set and cleared).
I have even gone so far as to use the initialization procedure for Port A in Example 12-1 of the datasheet. Comparators are turned off.
Here is the code:
Sorry for all the garbage in the code. That is the way it looks after all this time of trying to find the glitch.
John
MCU=16F1829 (not LF version)
Language=MPASM
Programmer/Debugger=MPLAB ICD3 using hardware debug
Defined SW1 as RA2
Programmer and same chip worked in demo described here: https://www.electro-tech-online.com/threads/driving-stepper-motor-gauges.144733/page-2#post-1226483
Program hangs here:
Program Counter (PC) goes to "goto Debounce" as if SW1 were low. Voltmeter on SW1 shows 4.95V. When SW1 is pressed, voltmeter goes to zero. Pull-up resistor on SW1 = 22K. Pressing SW1 has no on PC.
I am a bit confused about what the Watch window means:
PORTA does not change regardless of whether SW1 is pressed. Why does "RA2" show 8 bits? As the PC goes "btfss" and "goto debounce" RA2 changes from 0xCA to 0xCB (i.e., bit<0> is set and cleared).
I have even gone so far as to use the initialization procedure for Port A in Example 12-1 of the datasheet. Comparators are turned off.
Here is the code:
Code:
START
MOVLB 1 ;Bank1 |B1
MOVLW b'01110000' ; |B1
MOVWF OSCCON ;4xPLL disabled, 8MHz |B1
BTFSS OSCSTAT,HFIOFR ;HF internal oscillator ready |B1
GOTO $-1 ; |B1
MOVLW b'00001100' ; |B1
MOVWF TRISA ;PORTA 2(SW1) &3(MCLR) inputs |B1
CLRF TRISB ;all outputs |B1
CLRF TRISC ;all outputs |B1
BSF TRISC,5 ;set RC5 to input |B1
CLRF ADCON0 ;ensure ADC off (necessary?) |B1
CLRF ADCON1 ;ensure ADC off (necessary?) |B1
BCF OPTION_REG,7 ;enable WPU by individual latches |B1
MOVLB 2 ;APFCON0 bank |B2
BSF APFCON0,7 ;set RX/DT to RC5 |B2
BSF APFCON0,2 ;set TX/CK to RC4 DEBUG 08/07/15&&&&&&&&&&&&&&&&&&
BCF CM1CON0,C1ON ;turn off comparator 1 08.08.15 debonce still not working
BCF CM2CON0,C2ON ;turn off comparator 2
CLRF LATA ;080915 |B2
MOVLB 3 ;Bank3 |B3
CLRF ANSELA ;Turn off analog inputs |B3
CLRF ANSELB ;NB:comparators are off on reset |B3
CLRF ANSELC ; |B3
;Receive set-up and baudrate
BSF TXSTA, BRGH ;baud rate setup, 8-bit async |B3
BCF BAUDCON, BRG16 ;set 8-bit baud generator |B3
MOVLW .51 ;see Table 22-5 datasheet |B3
MOVWF SPBRG ;set baud 9600 ±0.16% |B3
BSF RCSTA, SPEN ;USART receive enable |B3
BCF TXSTA, SYNC ;USART config asynchronous, default=0 |B3
BSF RCSTA, CREN ;USART receive circuitry enable |B3
;/Receive set-up
MOVLB 4 ; |B4
BSF WPUA,2 ;enable WPUA for SW1 |B4
MOVLB 0 ; |B0
CLRF PORTA ;080915 |B0
Sorry for all the garbage in the code. That is the way it looks after all this time of trying to find the glitch.
John