Correct code for bank switching?

This is what i have:

; damn "example" says nothing about which interrupt vector or BANK to use ; NEEDS FIXING, "BANKSEL 0" and BANKSEL 1" issue SAME CODE BANKSEL 1 ; to get at INTCON, PIE1, PR2, TRISB MOVLW d'255' ; (PR2+1)*Timer2 prescalar value*Tcy ; 256 * 1 *(4/20e6) or

200nSec MOVWF PR2 ; 51.2uSec PWM period or about 19.5kHz ; Timer 2 ON, fastest scale, 10 bit resolution; MS 8 used BANKSEL 0 ; to get at INTCON, PIR1, TMR2, T2CON, CCPR1L, CCPR1H, CCP1CON MOVLW 0x04 ; TMR2ON bit; prescale & postscale bits = 0 MOVWF T2CON ; enable TMR2 with prescaler = 1 MOVLW 0x0F ; M0 to M3 all set MOVWF CCP1CON ; Activate PWM mode BANKSEL 1 ; to get at INTCON, PIE1, PR2, TRISB BCF TRISB,TRISB3 ; clear for PWM output pin 9 RB3 BANKSEL 0 ; to get at INTCON, PIR1, TMR2, T2CON, CCPR1L, CCPR1H, CCP1CON ; Nothing found in manual about these three. ; v---INTerrupt CONtrol BSF INTCON,PEIE ; set bit 6 PEripheral Interrupt Enable BCF PIR1,TMR2IF ; clear bit 1 Peripheral Interrupt Register ; TiMeR 2 Interrupt Flag

MOVLW D'0' ; zero PW MOVWF CCPR1L

Help?

Reply to
Robert Baer
Loading thread data ...

Robert Baer wrote in news:D6S_x.370$og6.324 @fx06.iad:

use

CCPR1H,

Register

BANKSEL expects a full register or RAM address and discards the bottom 7 bits. If you want to use it manually with a bank number, you need to set up some defines:

#define BANK0 0 #define BANK1 0x80 #define BANK2 0x100 #define BANK3 0x180

Then use it as: banksel BANK1 ;select bank 1

--
Ian Malcolm.   London, ENGLAND.  (NEWSGROUP REPLY PREFERRED)  
ianm[at]the[dash]malcolms[dot]freeserve[dot]co[dot]uk  
[at]=@, [dash]=- & [dot]=. *Warning* HTML & >32K emails --> NUL
Reply to
Ian Malcolm

Reply to
Robert Baer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.