回覆列表
  • 1 # 使用者3417633067606

    你確定是使用定時器改變頻率??

    下面的程式是使用定時器改變幅值的,你要是確定是定時器改變頻率的話,把具體的要求貼出來

    #include

    unsigned int i;

    code unsigned char Sin[128]={

    64,67,70,73,76,79,82,85,88,91,94,96,99,102,104,106,

    109,111,113,115,117,118,120,121,123,124,125,126,126,

    127,127,127,127,127,127,127,126,126,125,124,123,121,

    120,118,117,115,113,111,109,106,104,102,99,96,94,91,

    88,85,82,79,76,73,70,67,64,60,57,54,51,48,45,42,39,

    36,33,31,28,25,23,21,18,16,14,12,10,9,7,6,4,3,2,1,

    1,0,0,0,0,0,0,0,1,1,2,3,4,6,7,9,10,12,14,16,18,21,23,

    25,28,31,33,36,39,42,45,48,51,54,57,60};

    main()

    {

    TMOD=0X01;

    EA=1;

    ET0=1;

    TR0=1;

    TH0=(65535-1000)/256;

    TL0=(65535-1000)%256;

    while(1)

    {

    P1=Sin[i];

    }

    }

    void timer0(void) interrupt 1

    {

    TH0=(65535-1000)/256;

    TL0=(65535-1000)%256;

    i=i+1;

    if(i==128)i=0;

    }

  • 中秋節和大豐收的關聯?
  • 笑傲江湖三部曲是哪三部?