Having fun, need a bit of input do!

Hi Guys,

I’m not here to give out or complain, the self assemble programming board has worked great for me, no problems at all so far. I got it set up, could read and write the sample prog so far so good. Then i tried to write my own code, have got grips with the output side of things but not for the life of me can i get the input working. Now this is all new to me and im only working out as i go along and i HATE asking for help but i just cant see the problem. Basicly i have all the leds on the board flashing and i want to slow down the rate when sw1 is pressed. its a slighlty modified code i found on this page www.mstracey.btinternet.co.uk/pictutorial/progtut6.htm

this is my code

;
; RAM Definition
;
;==========================================================================

__MAXRAM H'01FF'
__BADRAM H'07'-H'09', H'0D', H'13'-H'14', H'1B'-H'1E'
__BADRAM H'87'-H'89', H'8D', H'8F'-H'91', H'93'-H'97', H'9E'
__BADRAM H'105', H'107'-H'109', H'10C'-H'11F', H'150'-H'16F'
__BADRAM H'185', H'187'-H'189', H'18C'-H'1EF'

;==========================================================================
;
; Configuration Bits
;
;==========================================================================

_BODEN_ON EQU H’3FFF’
_BODEN_OFF EQU H’3FBF’
_CP_ALL EQU H’03FF’
_CP_75 EQU H’17FF’
_CP_50 EQU H’2BFF’
_CP_OFF EQU H’3FFF’
_DATA_CP_ON EQU H’3EFF’
_DATA_CP_OFF EQU H’3FFF’
_PWRTE_OFF EQU H’3FFF’
_PWRTE_ON EQU H’3FF7’
_WDT_ON EQU H’3FFF’
_WDT_OFF EQU H’3FFB’
_LVP_ON EQU H’3FFF’
_LVP_OFF EQU H’3F7F’
_MCLRE_ON EQU H’3FFF’
_MCLRE_OFF EQU H’3FDF’
_ER_OSC_CLKOUT EQU H’3FFF’
_ER_OSC_NOCLKOUT EQU H’3FFE’
_INTRC_OSC_CLKOUT EQU H’3FFD’
_INTRC_OSC_NOCLKOUT EQU H’3FFC’
_EXTCLK_OSC EQU H’3FEF’
_LP_OSC EQU H’3FEC’
_XT_OSC EQU H’3FED’
_HS_OSC EQU H’3FEE’

__CONFIG        _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC

TRISB EQU 86H
STATUS EQU 03H
PORTB EQU 06H
COUNT1 EQU 20H
COUNT2 EQU 21H
TRISA EQU 85H
PORTA EQU 05H

	BSF		STATUS,5
	MOVLW	B'00000000'
	MOVWF	TRISB
	BCF		STATUS,5

	BSF		STATUS,5
	MOVLW	b'111111'
	MOVWF	TRISA
	BCF		STATUS,5

START
MOVLW B’11111111’
MOVWF PORTB
btfsc PORTA,0
call DELAY
CALL DELAY
MOVLW B’00000000’
MOVWF PORTB
BTFSC PORTA,0
CALL DELAY
CALL DELAY
goto START

DELAY

LOOP1 DECFSZ COUNT1,1
GOTO LOOP1
DECFSZ COUNT2,1
GOTO LOOP1
RETURN

END

i just robbed the configuation bit from the sample code.

Any help would be mucho appriciated

James

Hi,
Perhaps this is the problem: the comparator in the PIC was not disabled in your code. To do this put value 7 into register “CMCON”.
The reason for this: the comparator uses also portA pins for its own purposes, rendering them unusable an inputs (e.g. switches).

Extract from “Demo1.asm” delivered with the K8048 (in Examples):

[code]
; **********************************
; ** RESET : main boot routine **
; **********************************

RESET MOVLW B’00000111’ ;Disable Comparator module’s
MOVWF CMCON[/code]