To produce (what it thinks is) the best placement of banksel statements, the compiler needs to be able to add and delete them as needed. It doesn't currently have any way to take into account banksel statements placed by the user.
If you need to force a banksel into the assembly, try this:
asm banksel PORTA
But as a general rule, I'd suggest not doing this. The compiler should place the banksel statements where they are needed, and if it isn't then that's a separate bug that needs fixing. The compiler won't detect the presence of the forced banksel, and will automatically add another one before or after it.
(And also, keeping banksel out of the code does make it slightly more portable between 16F and 18F chips. An 18F running that code wouldn't need a banksel before the PORTA access.)
Is there a specific reason why banksel is needed there?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked at the ASM produced by GCB and then attempted to insert it in line for testing. Thus the compile/syntax error.
I have PIC ASM code from the past (before I started with GCB) and was doing this to test the feasibility of inserting sections of my past work into some GCB programs, rather than manually porting to GCB. The ASM code spans from 12F to 18F PIC.
Are there any other "Gotchas" that I may need to know about ?
Last edit: William Roth 2015-02-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is some code that I used for the 18f26k22. It has more than 256 SFR's, so ACCESS doesn't work.
Don't get into assembly much, or poke around the GCB inner workings. To get beyond the 256 SFR's I used both the banksel and BSR it appears. Couldn't say for sure if this code was even a working example? CCP1 is within standard ACCESS range.
#chip 18f26k22, 64#config MCLRE=INTMCLR, OSC=INTIO67, BOREN=OFF, PBADEN=OFF, CCP2MX=PORTB3 ',CCP3MX=PORTC6 #define blank PortC.7#define led1 PortA.5#define gsclk PortC.2 'CCP1 output#define TMR3CLK PortC.0 'T2CKI pin fed from CCP1 PWMdirTMR3CLKindirblankoutdirled1outdirgsclkoutdirPortB.3outdirPortC.1outdirPortB.5outdirPortC.6outdirPortBoutOSCCON=112'96=8Mhz NOTICE 112=16MHz current default of GCBasicSetPLLENON'enable INTOSC PLL (8 or 16MHZ)'*********** CCP1 *********************'sets 50% PWM duty cycle (CCP1X,Y = 0), i.e. 1 clk of 2 clk periodCCP1CON=b'00001100''setup PWM mode'set up hardware PWM with bare minimum valuesPR2=50'TMR2 period value, i.e. 2 instr. clks, approx. 8MHzCCPR1L=1'set for approx. 80% Duty cycleSetDC1B1OnSetDC1B0Off'dim TMRONE as word alias TMR1H, TMR1L'Use CCP1 PWM as Timer3 clock input (T3CKI) PortC.0'T3CON = b'10000000' ;Clock source from T3CKI, no prescale, secondary OSC enabled, sync system clock, 8 bit r/w'T3GCON = b'10000000' 'EnableTMRxcountcontrolbygate,sourceisTMR3gatepin'With PR2=1 CCP1 is about 8MHz with 16Mhz instr cycle (64/4)'Preload TMR1 for approx. 4096*(1/8000000)/16000000= 8192 cycles'TMR1 FFFF-1FFF=E000'TMRONE = 0xE000'T4CON = b'00000100''Set TMR4ON ON'HPWM 2, 200, 50 '2000kHz=notquite2Mhzonscope'Try using CCP3 as periodic interrupt with TMR3? no preload TMR3 in ISR everytime'*********** CCP2 *********************movlw12;stdPWMmodemovwfCCP2CON,ACCESSmovlw8;setCCP2PWMtimerasTMR4asmbankselCCPTMRS0iorwfCCPTMRS0movlw50;50instrcycles*16prescale*1/16000000=50usorfreq.of20kHzasmbankselPR4movwfPR4movlw20;40%D.C.withPR4=50:20(instrcycles)*16(prescale)*1/16000000=20usmovwfCCPR2L,ACCESSmovlw7;Prescaleis16,TMR4ON=1asmbankselT4CONmovwfT4CON'T2CON = b'10000000' ;Clock source from T3CKI, no prescale, secondary OSC enabled, sync system clock, 8 bit r/w'T2GCON = b'10000000' 'EnableTMRxcountcontrolbygate,sourceisTMR3gatepinCCPTMRS0=b'00001000''CCP2 uses TMR3 or TMR4'*********** CCP3 *********************'try movff with Wmovlb15'movwf BSRmovlw12;stdPWMmodemovlb15'movwf BSR'asm banksel CCP3CONmovffW,CCP3CON'movlw 15'movwf BSRmovlw128;setCCP3PWMtimerasTMR6movlb15'asm banksel CCPTMRS0movffW,CCPTMRS0'iorwf CCPTMRS0movlb15'movwf BSRmovlw100;100instrcycles*16prescale*1/16000000=100usorfreq.of10kHz'asm banksel PR6movlb15movffW,PR6'movwf BSRmovlw50;50%D.C.withPR4=100:50(instrcycles)*16(prescale)*1/16000000=50us'asm banksel CCPR3Lmovlb15movffW,CCPR3L'movwf BSRmovlw7;Prescaleis16,TMR6ON=1movlb15'asm banksel T6CONmovffW,T6CO............
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Problem:
The Compiler will return a syntax error on any line that contains BANKSEL directive.
GCB.exe is FEB 5, 2015
Example Code: (DOES NOT COMPILE)
.
.
If banksel PORTA line is removed, the code will compile and the compiler will add the banksel to the final ASM code.
.
.
To produce (what it thinks is) the best placement of banksel statements, the compiler needs to be able to add and delete them as needed. It doesn't currently have any way to take into account banksel statements placed by the user.
If you need to force a banksel into the assembly, try this:
But as a general rule, I'd suggest not doing this. The compiler should place the banksel statements where they are needed, and if it isn't then that's a separate bug that needs fixing. The compiler won't detect the presence of the forced banksel, and will automatically add another one before or after it.
(And also, keeping banksel out of the code does make it slightly more portable between 16F and 18F chips. An 18F running that code wouldn't need a banksel before the PORTA access.)
Is there a specific reason why banksel is needed there?
Thanks Hugh
I looked at the ASM produced by GCB and then attempted to insert it in line for testing. Thus the compile/syntax error.
I have PIC ASM code from the past (before I started with GCB) and was doing this to test the feasibility of inserting sections of my past work into some GCB programs, rather than manually porting to GCB. The ASM code spans from 12F to 18F PIC.
Are there any other "Gotchas" that I may need to know about ?
Last edit: William Roth 2015-02-14
Here is some code that I used for the 18f26k22. It has more than 256 SFR's, so ACCESS doesn't work.
Don't get into assembly much, or poke around the GCB inner workings. To get beyond the 256 SFR's I used both the banksel and BSR it appears. Couldn't say for sure if this code was even a working example? CCP1 is within standard ACCESS range.