Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic12f2580 jump table

Status
Not open for further replies.

RASH

New Member
I'm new to the 18F2580, I'm having a problem in updating the PC (PCLAT) on time while performing the instruction ADDWF PCL,F.

How can I predict the correct PCL value and add my variable to hit the desires GOTO or BRA instruction.

Thank you all for the help
 
This is what I use on the 18F series.
There needs to be a register called "index", and this code will cause a jump to option_[index]

If index is too big for the lookup table, the code will jump to fail_code.

This can be used for any number of options up to 255

Code:
	movlw	high (lookup_start)
	movwf	pclath
	movlw	(lookup_end - lookup_start)/2
	subwf	index, w
	bc	fail_code
	rlncf	index, w
	addlw	low (lookup_start)
	btfsc	status, carry
	incf	pclath, f
	movwf	pcl
lookup_start
	bra	option_0
	bra	option_1
	bra	option_2
	bra	option_3
	bra	option_4
	bra	option_5
.
.
.
.
	bra	option_last
lookup_end


fail_code
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top