On Fri, 16 Jun 2000, Tony Nixon wrote:
{Quote hidden}> Nikolai Golovchenko wrote:
> >
> > Tony,
> > If you need to cycle FSR from 0x40 to 0xFF and again, may be this will
> > work:
> > incf FSR, f ;increment FSR
> > skpnz ;check for overflow from 255 to 0
> > bsf FSR, 6 ;if overflow fix FSR to 0x40
> >
> > FSR should be preloaded with a number in 0x40-0xFF range.
>
> Thanks for the tip.
>
> I was trying to do it with the least instruction count and be
> 'isosynchronous'.
>
> I learnt that here ;-)
>
>
> What I am trying to do is output an 8 bit value to PortB as quick as
> possible. The data is coming from RAM at address 0x40 to 0x7F. To avoid
> the problems I had with quick succession BSF BCF instructions I had to
> do the following...
>
> WaveData7 bsf FSR,6
> movf INDF,W
> incf FSR
> movwf PORTB
> bcf FSR,7
> goto WaveData7
Tony,
If you're trying to squirt out a wave form as fast as possible and your table is
only 0x40 (64) bytes then you could unroll the loop:
begin:
movf 0x40,w
movwf portb
btfsc porta,should_quit_bit
goto through
movf 0x41,w
movwf portb
btfsc porta,should_quit_bit
goto through
...
movf 0x7f,w
movwf portb
goto begin
4-isochronous cyles per sample with the ability to break out of the loop.
If you don't want the break to be under software control, then this can be
reduced to 3 cycles.
The only problem with this approach for an 'arbitrary waveform generator' is
that the output frequency is fixed. I've done this kind of thing before and
varied the output frequency by vary the frequency of the clock signal fed to the
pic. In my case, I just took a function generator and hooked to the xtal pins,
pumped in a variable frequency, 0-5 V square wave.
If you don't have a function generator at your disposal, then the next best
thing is a phase accumulator. Essentially what you do is store one full cycle's
worth of data somewhere - either in ram or rom - and step through it at a
constant rate, but vary the step size according to the frequency. This is the
approach my sine wave generator uses. In my case the sine wave (or 1/4 'th of
it) is stored in a table.
The phase accumulator could be used in your case too. About 10 cycles per sample
would be needed...
{Quote hidden}>
> I guess the internal bus can't keep up with multiple read/write/modify
> instructions on the same register.
>
> This is a short as I can get it which results in a repetition rate of
> about 2.2KHz at 4MHz. I just got the ROMzap software to do sine,
> rectified, triangle and arbitrary waves from PORTB. They look quite good
> on the CRO with a simple R2R, but filtering is obviously needed. The
> arbitrary waves are good. Just draw them on the PC screen and out of
> PORTB they come.
>
> I was hoping to have this done sooner, but some friends arrived here to
> do some choir singing with the Melbourne Philharmonic Orchestra so we
> took time off to show them around. Strange thing was, they live in
> Chandler Arizona right near the Microchip HQ, but they didn't have a
> clue what a PIC was.
>
> --
> Best regards
>
> Tony
>
>
http://www.picnpoke.com
>
RemoveMEsalesTakeThisOuT
picnpoke.com
>