I
ivan
Hi all,
What is the best way to generate many square waves concurrently using only
one timer?
The way I have thought is using arrays. So for example for a wave with freq
770Hz I can generate it by using an interrupt every 0.1msec (10KHz) with the
timer and using 10KHz/770=13 elements of the array, hence I scan the
elements of the array which will look like
BYTE b770Hz [14] EQ {1,1,1,1,1,1,1,0,0,0,0,0,0};//this would be global
so the interrupt routine will look like:
static BYTE bIdx=0;
//compute array index
if(bIdx > 13)
bIdx = 0;
else
bIdx++;
//output wave
if(b770Hz[bIdx])
PCOUT |= 0x01;
else
PCOUT &= ~0x01;
Is there a better way of doing this? Maybe something with a better accuracy
on the time axis?
Thanks in advance
Ivan
What is the best way to generate many square waves concurrently using only
one timer?
The way I have thought is using arrays. So for example for a wave with freq
770Hz I can generate it by using an interrupt every 0.1msec (10KHz) with the
timer and using 10KHz/770=13 elements of the array, hence I scan the
elements of the array which will look like
BYTE b770Hz [14] EQ {1,1,1,1,1,1,1,0,0,0,0,0,0};//this would be global
so the interrupt routine will look like:
static BYTE bIdx=0;
//compute array index
if(bIdx > 13)
bIdx = 0;
else
bIdx++;
//output wave
if(b770Hz[bIdx])
PCOUT |= 0x01;
else
PCOUT &= ~0x01;
Is there a better way of doing this? Maybe something with a better accuracy
on the time axis?
Thanks in advance
Ivan