|
|
Here's the code, again it's not very tidy, but it's only really a little test
#include "qc.h"
//The timer control registers
#define TCR_0 (*(unsigned char *)0xffc8) #define TCSR_0 (*(unsigned char *)0xffc9) #define TCORA_0 (*(unsigned char *)0xffca) #define TCORB_0 (*(unsigned char *)0xffcb) #define TCNT_0 (*(unsigned char *)0xffcc) #define STCR (*(unsigned char *)0xffc3)
#define WAIT_HZ 40 //The delay to give 16KHz
unsigned char speak[]={ 0x21,0x00,0x11,0x22,0x33,0x21,0x11,0x21,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x01, 0x11,0x35,0x49,0xFF,0xE7,0x66,0x43,0xCD,0xDC,0xC9,0x54,0x21,0x56,0x30,0x24,0x53, 0x33,0x55,0x54,0x02,0x56,0x8A,0xBB,0x84,0x02,0x45,0x79,0x87,0x43,0x21,0x01,0x22, 0x22,0x22,0x33,0x11,0x00,0x00,0x01,0x10,0x00,0x00,0x10,0x01,0x11,0x00,0x11,0x11,
deletia... and lots of it!
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
int main() {
int j; unsigned char bDelay;
LCDPrints(" READY"); //give some control so we don't have to keep removing the batteries while (getc()==RUN) { LCDPrints(" RUN"); //turn off all interupts __asm__ ("\torc #0x80,ccr\n");
//Set the Timer Control Register 0 to 0 so nothing happens while we set things up TCR_0=0;
//set the clock to increment the counter every 2 clock cycles - very quick! STCR = 0x00; //set bit 0 TCR_0=9; //set bit 0 for 2x, bit 3 for clear count on A //set up the output to low on compare-match A, high on a compare match B TCSR_0=9; //32 gives reasonable control of the amplitude TCORA_0=32; //Run through the data for (j=0;j<sizeof(speak);j++) {
//set up the amplitude hi nybble TCORB_0=(speak[j] & 0xF0) >> 4; TCNT_0=0; //wait a moment for (bDelay=0;bDelay<WAIT_HZ;bDelay++); //set up the aplitude lo nybble TCORB_0=speak[j] & 0xF; TCNT_0=0; //wait a moment for (bDelay=0;bDelay<WAIT_HZ;bDelay++); }
//Set the Timer Control Register back to off 0 TCR_0=0;
//turn interrupts back on __asm__ ("\tandc #0x7f,ccr\n"); LCDPrints(" READY"); } LCDPrints(" DONE"); getc(); return 0;
}
|
|