Hi,
I am trying to generate an audio wave using the PWM of a 18F2685 working at 32 MHz (with PLL)
The sampling rate is about 58 kHz, provided by the PWM.
I'am using PBP 3.0 and a PicKit 2 for debugging.
The waveform is stored in bytes in a table, called TABWF and stored in the program memory.
TABWF ends with $7F.
Some background tasks are executed and are periodiaclly interrupted by the TMR2 used for the PWM.
The IT program simply pushes the current table value to the PWM and increments the table look-up pointer.
Here is how the background program looks (extract) :
NOTE_IT : ; Initialisation
I = 0
INTCON = 000000
PIE1.1 = 1
LOOP :ReadCODE(TABWF + I), XIF (X <> $7F) THEN; some simple maths hereELSEI = 0ENDIFGOTO LOOP
And the IT Program :
ASM
IT_NOTE :clrf BSRmovf _X,Wmovwf W,CCPR1Lincf _Iretfie FASTENDASM
Basic and very simple, but it does not work !
The IT program works, I is correctly incremented but the background program is sticked to the ReadCode instruction.
It looks like the ReadCode instruction execution time is greater that the IT period, so ReadCode is never completed and starts again and again from the beginning.
Any solution to that ?
The hereabove code is a very small part of my application. Actually, the background task is much more complex.
I'm afraid that the program remains sticked to any long execution time BASIC instruction it meets...
Thank you for your help
MikeBZH
Bookmarks