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.

help with code program error.. very urgent~~ T.T~~

Status
Not open for further replies.

kitty_cute

Newbie level 6
Joined
Apr 30, 2010
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Malaysia
Activity points
1,368
MPLAB IDE v8.46
language use: assembly

part of program:

STARTUP code ; linker directive
goto Start

PORT1 code ; linker directive

Start
call InitLCD ; Initialize LCD registers
bsf STATUS,RP0 ; Bank 1
bsf TRISA,4 ; RA4 as input
bcf TRISD,1 ; set RD1 as motor output
movlw b'01110000' ; select the 8Mhz internal oscillator
movwf OSCCON movlw 0xFF ; select 7.9 kHz PWM
movwf PR2
bcf STATUS,RP0 ; Return to Bank 0
movlw b'00001100' ; pwm mode
movwf CCP2CON
bsf T2CON,TMR2ON ; turn on PWM
call InitLCD ; Initialize the LCD module
clrf CCPR2L ; Clear Duty Cycle
bsf ADCON0,ADON ; Turn the ADC module on


State1
clrf PORTD ; clear all portD
bsf PORTD,1
bsf PORTD,6
bsf PORTD,5
bcf PORTD,4 ;changes from bsf
btfsc PORTA,4 ; wait for switch to be press. YES or NO?
Goto State1 ; if no, go back state1

LoopOuter ; if switch is pressed.

bsf ADCON0,GO_DONE ; Start a conversion
bcf PORTD,1 ; On LED for Start/Stop

LoopInner
btfsc ADCON0,GO_DONE ; Wait for conversion to complete
goto LoopInner ; if not complete, go back reloop
movf ADRESH,w ; Move result to W
call DisplayDecimal ; Display the result (in decimal)

~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

wish to make some adjustment on instead wait for the switch to be press , i wish someone can help me on change the code to press 1 time then the value will always show on LCD. press another time it will off.

Added after 56 seconds:

the code is to program a PIC chip pic16f917
 

Hi,

Yes it is quite easy to do what you want, however you do not show the rest of the program loop - assume there are other functions after you display the adc value.

Once the switch is pressed for the first time do you want it to keep displaying just the one adc value until the switch is pressed again or do you want it to re-read and re-display the adc value every program loop.
 

the rest of program is the speed.
i want it keep display the value of input by press 1 time until press the other time it will off.

Added after 32 minutes:

i still gt one problem with the code whereby the LCD does not showing any value out.

Added after 9 minutes:

wp100 said:
Hi,

Yes it is quite easy to do what you want, however you do not show the rest of the program loop - assume there are other functions after you display the adc value.

Once the switch is pressed for the first time do you want it to keep displaying just the one adc value until the switch is pressed again or do you want it to re-read and re-display the adc value every program loop.

i want it to re-read and re-display the adc value every program loop. thanks for reply ^^.

Looking forward for your reply soon and i sent the program to you.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top