Hi. I have a code that generates sine wave that shoul have 2600Hz frequency. When I run this code in Keil i can't see sine wave on logic analyzer so I dont know the frequency of sine wave. how can i solve this problem? thanks for all!
The Code
#include <stdio.h> #include <ADuC841.h>
sbit LED = 0x0B4;
void timer0(void) interrupt 1 //interrupt no. 1 for Timer 0 { TH0=0xFC; TL0=0xFB; }
void main (void) {
unsigned code values[50][2]={{0x0F, 0x7F},{0x08, 0x11},{0x01, 0x80},{0x07, 0xBF},{0x0D, 0x87}, {0x08, 0x91},{0x03, 0x68},{0x07, 0x02},{0x0B, 0xB7},{0x09, 0x88}, {0x05, 0x19},{0x05, 0xD4},{0x0A, 0x2C},{0x0A, 0xE7},{0x06, 0x78}, {0x04, 0x49},{0x08, 0xFE},{0x0C, 0x98},{0x07, 0x6F},{0x02, 0x79}, {0x08, 0x41},{0x0E, 0x80},{0x07, 0xEF},{0x00, 0x81},{0x08, 0x01}, {0x00, 0x81},{0x07, 0xEF},{0x0E, 0x80},{0x08, 0x41},{0x02, 0x79}, {0x07, 0x6F},{0x0C, 0x98},{0x08, 0xFE},{0x04, 0x49},{0x06, 0x78}, {0x0A, 0xE7},{0x0A, 0x2C},{0x05, 0xD4},{0x05, 0x19},{0x09, 0x88}, {0x0B, 0xB7},{0x07, 0x02},{0x03, 0x68},{0x08, 0x91},{0x0D, 0x87}, {0x07, 0xBF},{0x01, 0x80},{0x08, 0x11},{0x0F, 0x7F},{0x07, 0xFF}};
DACCON = 0x0D;
DAC0H = 0x08; DAC0L = 0x00;
TMOD = 0x01; // mode1 of Timer0 TH0 = 0xFC; // initial values loaded to timer TL0 = 0xFB; IE = 0x82; // enable interrupt TR0 = 1; //start timer while(1) { int i; for ( i = 0 ; i < 50; i++) { DAC0H = values[i][0]; DAC0L = values[i][1]; } LED ^= 1; } }