mess Posted December 30, 2006 Report Share Posted December 30, 2006 Hi,I'm working on a small 16f88 project in assemblerusing 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 16f88my 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 Quote Link to comment Share on other sites More sharing options...
mess Posted December 30, 2006 Author Report Share Posted December 30, 2006 the answer to the first question was on page 11 of the datasheetso this one is solved :)only the wreg problem remains... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted December 31, 2006 Report Share Posted December 31, 2006 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. Quote Link to comment Share on other sites More sharing options...
mess Posted December 31, 2006 Author Report Share Posted December 31, 2006 I have modified the code to avoid the WREG stuffonly 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... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted December 31, 2006 Report Share Posted December 31, 2006 Yeh it's tough being a pioneer! But we love you for it :-* ;D Quote Link to comment Share on other sites More sharing options...
mess Posted January 2, 2007 Author Report Share Posted January 2, 2007 Lol :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.