/* DA.C * * Analog Output Routines for the SBC1190 with 4 Channel D/A option * * This example outputs values from 0 to FFFh to all four channels * of the DAC. * * 8/3/98 */ #include #include #define PCB 0x0FF00 /* default base address after reset */ #define P1DIR PCB+0x050 #define P1CON PCB+0x054 #define P1LTCH PCB+0x056 #define P2DIR PCB+0x058 #define P2CON PCB+0x05C #define P2LTCH PCB+0x05E #define RTCDTA1 0x80 #define RTCDTA0 (RTCDTA1 ^ 0xFF) #define RTCCLK1 0x40 #define RTCCLK0 (RTCCLK1 ^ 0xFF) #define RTCRST1 0x80 #define RTCRST0 (RTCRST1 ^ 0xFF) #define DACCS1 0x4 #define DACCS0 (DACCS1 ^ 0xFF) #define LOADREG 0x3000 /*-----------------------------------------------------------------------* * SendDacWord(unsigned dacwd) * * * * This procedure sends a 16-bit word to the serial DAC. * * It is assumed that SCLK is low and /DACCS * * is low upon entry to this routine. The data is sent starting with * * bit 15. * * Return value : none * *-----------------------------------------------------------------------*/ void SendDacWord(unsigned dacwd) { register int n, p2dta; p2dta = inp(P2LTCH); for(n=15; n>=0; n--) { if(dacwd&(1<