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.

no branch instructions in pic16f877a

Status
Not open for further replies.

JAMAL JIMI

Member level 1
Member level 1
Joined
Dec 14, 2013
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
233
Hi everybody......
I am trying to program pic16f877's ADC but there is no branch instruction in the instruction set.....
So how can I display the ADC result on the LCD in the form of numbers?????

Plzzzzzz help me.....
 

The BTFSS and BTFSC provide a means of conditional jumps:


Simple PIC Conditional Jump Using BTFSC

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;
 
include p16f877.inc ;Include file for register definitions
 
; ************************************************************
; equates
 
count equ 0x25 ;Manually assign register address!
 
; ************************************************************
; start at the reset vector
 
org 0x000 ; Set origin at memory address 000
nop ; very important - required for debugger
 
Start bcf STATUS,RP0 ; go to BANK 0 by setting
bcf STATUS,RP1 ; RP1:RP0 to 0 0.
 
; Initialize contents of variables.
;
 
movlw 0x0A ; Initialize count to 10 decimal by
movwf count ; setting W and moving W -> count.
 
;
; Do the simple loop.
 
loop decf count,F ; count = count - 1.
btfsc STATUS,Z ; Skip next instruction if Z=0.
stop goto stop ; End program.
goto loop ; Continue looping!
 
End



BigDog
 

Dear I wasn't mean that........ I want to say that if, for example, i have some specific value in the ADC result register and i want to use that value to display a specific number on the lcd then what will i do............for example in 89c51 with an external 8 bit ADC connected to port1 i can display its value with the help of these instructions............



Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
org 0h
                    mov a,#0ffh
                    mov p1,a             ;make p1 as input port
again:            mov r1,p1            ;move p1 value to r1
                    mov a,#0afh
                    cjne r1,a,again     ;if equal diplay 24 on the lcd
                    lcall dis24
                    ..........
                    ........
                    .....
dis24:
 
                    ;commands for displaying 24 on the lcd
                    ..........
                    .............
                    .........
                    ret
                    end

 
Last edited by a moderator:

If you want to display a specific something, such as a number or text string, based on something else, such as an ADC value, then you do a conditional branch as BigDog shows. I would be cautious and probably set the trigger ADC value to a range or to a greater than/less than flag (i.e. test the ADC value, if it meets that test, then set a flag bit in a flag register, then test that flag bit for the conditional branch). BigDog's example uses the zero bit of the Status register as a flag. I usually have just a "flag" register in addition that gives me 8 bits to check for various conditional branches, if needed.

@BigDog: Does your jump to "stop" (i.e., goto stop) compile? ;)

John
 

@John

Actually, it is not my code, I simply found the example during a quick search.

However, I see no reason why it shouldn't compile.

It basically puts the execution flow into an endless loop.

Perhaps if I find the time I'll attempt to assemble it.


@Jamal

Rather than posting additional examples, perhaps you should examine the following Gooligum tutorials in PDF form with downloadable source code:

MPLAB based IDE

**broken link removed**

**broken link removed**


MPLAB X based IDE

**broken link removed**

**broken link removed**


The tutorials are actually quite good covering both the Baseline and Midrange PIC Programming in Assembly and C using both the original MPLAB and the newer MPLAB X IDEs.

I would recommend studying the first two tutorials, they cover the majority of PIC Assembly Language required to master the topic.


BigDog
 

Hi,

Think you mean like this ..?

Code:
; 		adc routine result in ADRESH lower 2 bits ignored

		movlw	0xAF  ; reference value

		subwf	 ADRESH

		btfsc	STATUS,Z
		goto	lcd_output   ; is equal

		btfsc	STATUS,C
		goto	lcd_output   ; ADRESH is greater
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top