|
這個晶片是
STC-VC33
TMS320
VC33
DSP
以上是這晶片的介紹
我要執行1個程式
程式內容是
/* file: DAC_square */
#include "stdio.h"
void delay(int time);
void set_timer0_freq(int freq);
volatile unsigned int *AD_CS=(unsigned int*)0xc00000;
volatile unsigned int *CMD_LD=(unsigned int*)0xc06000;
volatile unsigned int *LATCH_OE=(unsigned int*)0xc07000;
volatile unsigned int *DA0_CS= (unsigned int*) 0xc01000;
volatile unsigned int *DA1_CS= (unsigned int*) 0xc01001;
volatile unsigned int *DA2_CS= (unsigned int*) 0xc01002;
volatile unsigned int *DA3_CS= (unsigned int*) 0xc01003;
volatile unsigned int *strb=(unsigned int*)0x808064;
volatile long *TMR0_CTRL = (long*) 0x808020;
volatile long *TMR0_CNT = (long*) 0x808024;
volatile long *TMR0_PERIOD = (long*) 0x808028;
#define volt_offset 0.3;
int a=0, Flag=0, Amplitude=1;
int L;
/**/
printf("\Please enter the frequency");
scanf("%d",&L);
/**/
main()
{
*strb=0xf10b8;
asm("\tLDI 0h,IF");
asm("\tLDI 0h,IE");
set_timer0_freq(2*L) ;
delay(100);
asm("\tor 2000h,ST");
asm("\tor 100h,IE");
delay(100);
while(1)
{ a++; }
}
void c_int99(void)
{ }
void c_int09(void)
{
if (Flag==0)
{ *DA0_CS=3276*Amplitude+32768+3276*volt_offset;
Flag=1; }
else
{ *DA0_CS=-3276*Amplitude+32768+3276*volt_offset;
Flag=0; }
asm("\t NOP");
asm("\t NOP");
}
void delay(int time )
{
int a;
for(a=0;a<time;a++);
}
void set_timer0_freq(int freq)
{
*TMR0_PERIOD=30000000/freq;
*TMR0_CTRL =0x2c1;
}
以上執行結果,會出現1個視窗詢問"Please enter the frequency"
要求我輸入frequency
這樣在示波器上就會出現我所輸入的frequency值
我想要在以上程式在加入個可以輸入duty cycle
要讓他會在詢問我"Please enter the duty cycle"
並且我輸入duty cycle的值後,是正確的
請求各位大大協助 |
|