Jump to content

Recommended Posts

Posted

Hi,

I'm working on a small 16f88 project in assembler

using the speakjet code as template...

*Can someone explain the use of SWITCHBANK_...?

I understand the banked system with pic18f... with BANKSEL variable

but I don't know when to switch banks with a 16f88

my variable declarations:

shared_ram		udata_shr
W_TMP			res	1
STATUS_TMP		res	1
FSR_TMP			res	1

gpr0			udata
NOISE			res 3
TMP1			res 1
...and the code without switches
IRQ_Handler_NoiseInt
	;; noise generator
	;; new bit = b18 exor b13
	;; shift NOISE one to the left, insert new bit as LSB
	; TMP1 = NOISE >> 2
	rrf		NOISE, W
	rrf		WREG, W
	movwf	TMP1
	; WREG = NOISE+1 >> 4
	rrf		(NOISE+1), W
	swapf	WREG, W
	; WREG = WREG exor TMP1
	xorwf	TMP1, W
	; carry = LSB of WREG
	rrf		WREG, W
	; three byte shift register
	rlf		(NOISE+2), f
	rlf		(NOISE+1), f
	rlf		NOISE, f

	; ouput new shift register value to RA2
        ; the output value is in the carry flag from last shift
	bc		IRQ_Handler_NoiseInt_Out_1
        bcf		PORTA, 2
	goto	IRQ_Handler_NoiseInt_End
IRQ_Handler_NoiseInt_Out_1
	bsf		PORTA, 2
IRQ_Handler_NoiseInt_End
	goto IRQ_End

*I also get a assembler error on WREG (symbol not defined)

does anybody knows how to solve this?

  Michaël

Posted

the answer to the first question was on page 11 of the datasheet

so this one is solved  :)

only the wreg problem remains...

Posted

I'm not 100% sure how/why it works, but I know the 16F8* doesn't have a W register SFR. Hopefully someone can explain wtf that's all about, obviously the W register exists, but F&^ if I know why it can't be directly addressed....

In short you'll have to MOVWF your data to a variable and do the bitshift there.

Posted

I have modified the code to avoid the WREG stuff

only to find out that I can't access my programmer until next week  :(

In the meanwhile the program is running on a core :-)

this was a lot of effort for a simple digital noise generator...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...