PDA

View Full Version : Compile problems



ffindog
- 24th June 2007, 12:12
I'm having some trouble getting this code to compile a friend of my wrote it but does not have time to help me with it. he used a compiler from ohsonsoft

I don't know enough about pbp or assembly to get it to work, so any help would be great.

I'm told PBP does not run fast enough for this code and it has to be done in ASM???

'(96 bursts of 16 cycles @ 56kHz) at 1800Hz
'Osc at 16Mhz
'PIC16F628A
cnt var Byte '96 pulse counter
sixt var Byte '16 cycle counter
start:
cnt = 96
TRISB = %00100000 'RB5 as trigger input
PORTB = 0x00 'RB0 as IR output, RB1 as 1800 Hz test output
PR2 = 26 'timer 2 compare for 56kHz 1/2 period
T1CON = %00000000 '1:1 prescale TMR1 off
T2CON = %00000000 '1:1 prescale TMR2 off
trigger:
@ btfss portb,5 'wait for trigger RB5 = 1
Goto trigger
'debounce code goes here if required
@
sixt = 16
PORTB = 0x02 'set 1800Hz output pin on
@ movlw 0x01 'bit for toggling output RB0
@ bsf T2CON,TMR2ON 'turn on TMR2
pulseon:
@ xorwf portb,f 'toggle RB0 IR output
@ clrf TMR2
pwaiton:
@ btfss PIR1,TMR2IF 'wait for TMR2 flag
Goto pwaiton
@ bcf PIR1,TMR2IF 'clear TMR2 flag
@ nop
@ nop
@ nop
pulseoff:
@ xorwf portb,f 'toggle RB0 IR output
@ clrf TMR2
pwaitoff:
@ btfss PIR1,TMR2IF 'wait for TMR2 flag
Goto pwaitoff
@ bcf PIR1,TMR2IF 'clear TMR2 flag
@ nop
@ decfsz sixt,f 'count cycles
Goto pulseon
@ clrf portb 'else clear outputs
@ bcf T1CON,TMR1ON 'turn off TMR1
TMR1H = 0xfb 'time interval for 1800Hz 1/2 period
TMR1L = 0xd0 '(2^16 - 277.7*4) - 18*4 - 28*4 adjustments
@ bcf pir1,tmr1if 'clear TMR1 flag
@ bsf T1CON,TMR1ON 'turn on TMR1
@ bcf t2con,tmr2on 'turn off TMR2
killtime:
@ btfss pir1,tmr1if 'wait for TMR1 flag
Goto killtime
@ bcf pir1,tmr1if 'clear TMR1 flag
@ bcf T1CON,TMR1ON 'turn off TMR1
@ decfsz cnt,f 'count down 96 pulses
Goto top 'if not output 96 yet
Goto start 'else return to await next firing


Thanks for looking
Clinton.

BobK
- 24th June 2007, 14:28
Hello Clinton,

I don't know if you are aware that there are quite a few variations of the Basic language for PICs. OshonSoft's is different from MELabs which is what this forum is for. I would suggest you check out www.oshonSoft.com and see if they have a forum that might be able to help you. There also may be someone on this forum that uses both PBP here and the variation from OshonSoft that hasn't seen this post yet. OshonSoft's big claim is their simulator that allows you to see how your program will run on a PC display with an IDE for around $20.00.

Keep checking this site to see if someone is able to help you. Good luck in your venture!

BobK

ffindog
- 25th June 2007, 02:51
Thanks for the info.

I'm hoping to get it to work under MELabs so i can use it in some of my existing programs...

Clinton.