Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PBP Code not working

Status
Not open for further replies.

yugal

Junior Member level 2
Joined
Mar 17, 2007
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Usa
Activity points
1,422
hi
am new to micro controller
this is my first code but not working . please help to correct this

'***************************************************************
'* Name : Matrix-A.BAS
'* Author : Y.K.SHARMA
'* Date : 4/18/2013
'* Version : 1.0
'* Notes : Ic pic16F676 COMPILIER PBP2.60
'***************************************************************
@ DEVICE pic16F676
@ DEVICE pic16F676, WDT_OFF
@ DEVICE pic16F676, PWRT_ON
@ DEVICE pic16F676, PROTECT_ON
@ DEVICE pic16F676, MCLR_OFF
@ DEVICE pic16F676, INTRC_OSC_NOCLKOUT
'***********************************************
TRISA = %011000
TRISC = %000000
SEQ VAR BYTE
'***********************************************
LED1 VAR PORTC.0
LED2 VAR PORTC.1
LED3 VAR PORTC.2
LED4 VAR PORTC.3
LED5 VAR PORTC.4
LED6 VAR PORTC.5
LED7 VAR PORTA.0
LED8 VAR PORTA.1
LED9 VAR PORTA.2
LED10 VAR PORTA.5

PBUP VAR PORTA.3
PBDN VAR PORTA.4

SEQ = 4
PORTC = 0
PORTA = 0
CMCON = 7
ANSEL = 0
'***************************************
LOOP:
IF PBUP = 0 THEN UPP
IF PBDN = 0 THEN DNN
PAUSE 50
GOSUB ACTIONS:
GOTO LOOP
'**************************
UPP:
IF SEQ = 1 THEN RRT
SEQ = SEQ + 1
PAUSE 50
GOTO RRT
DNN:
IF SEQ = 7 THEN RRT
SEQ = SEQ - 1
PAUSE 50
RRT : RETURN

'*******************************************
ACTIONS:
IF SEQ = 1 THEN
LED1 = 1 :LED2 = 0 :LED3 = 0 :LED4 = 0 :LED5 = 0 :LED6 = 0 :
LED7 = 0 :LED8 = 0 :LED9 = 1 :LED10 = 1 :
ENDIF
IF SEQ = 2 THEN
LED1 = 0 :LED2 = 1 :LED3 = 0 :LED4 = 0 :LED5 = 0 :LED6 = 0 :
LED7 = 0 :LED8 = 1 :LED9 = 0 :LED10 = 1 :
ENDIF
IF SEQ = 3 THEN
LED1 = 0 :LED2 = 0 :LED3 = 1 :LED4 = 0 :LED5 = 0 :LED6 = 0 :
LED7 = 0 :LED8 = 1 :LED9 = 1 :LED10 = 0 :
ENDIF
IF SEQ = 4 THEN
LED1 = 0 :LED2 = 0 :LED3 = 0 :LED4 = 1 :LED5 = 0 :LED6 = 0 :
LED7 = 0 :LED8 = 0 :LED9 = 1 :LED10 = 1 :
ENDIF
IF SEQ = 5 THEN
LED1 = 0 :LED2 = 0 :LED3 = 0 :LED4 = 0 :LED5 = 1 :LED6 = 0 :
LED7 = 0 :LED8 = 0 :LED9 = 1 :LED10 = 1 :
ENDIF
IF SEQ = 6 THEN
LED1 = 0: LED2 = 0:LED3 = 0 :LED4 = 0 :LED5 = 0 :LED6 = 1 :
LED7 = 0 :LED8 = 1 :LED9 = 1 :LED10 = 0 :
ENDIF
IF SEQ = 7 THEN
LED1 = 0 :LED2 = 0 :LED3 = 0 :LED4 = 0 :LED5 = 0 :LED6 = 0 :
LED7 = 1 :LED8 = 0 :LED9 = 1 :LED10 = 1 :
ENDIF
PAUSE 50
RETURN
'***************************************************************
 

Use something like

LEDPORT VAR PORTC

and if you want to turn ON first 5 leds on PORTC then use

IF SEQ = 1 THEN

LEDPORT = 0b00011111

ELSE IF SEQ = 2

LEDPORT = 0b00010101

END IF


Which version of PBP are you using?
 

Hi jayanth.devarayanadurga. thanks for quick reply
i am using PBP2.60 .yugal
 

hi jayanth.devarayanadurga
actually push button is not working.After start up led is glowing as per seq, but after pushing pbup or pbdn seq not change. guide me please
thanks
yugal
 


Code - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
loop:
    If pbup = 0 then 
        pause 50
        if pbup = 0 then 
            upp
        end if
    end if
 
    if pbdn = 0 then 
        pause 50
        if pbdn = 0 then 
            dnn
        end if
    end if
 
gosub actions:
Goto loop

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top