00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "aduc7026.h"
00019
00020 #include "global.h"
00021 #include "d2a.h"
00022
00023
00024 void d2aInit(void)
00025 {
00026 #define DACBYP (1<<6)
00027 #define DACCLK (1<<5)
00028 #define DACCLR (1<<4)
00029 #define DACRANGE_PWRDOWN (0x00)
00030 #define DACRANGE_DACREF (0x01)
00031 #define DACRANGE_AREF (0x02)
00032 #define DACRANGE_AVDD (0x03)
00033
00034
00035 DAC0CON |= DACCLR | DACRANGE_AVDD;
00036 DAC1CON |= DACCLR | DACRANGE_AVDD;
00037 DAC2CON |= DACCLR | DACRANGE_AVDD;
00038 DAC3CON |= DACCLR | DACRANGE_AVDD;
00039 }
00040
00041 void d2aSet(int channel, int level)
00042 {
00043 DAC->Channel[channel].Data = level<<16;
00044 }