;Disclaimer. ; THIS PROGRAM IS PROVIDED "AS IS". MICROTREND SYSTEMS INC. MAKES NO ; WARRANTIES OR REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, ; INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS ; FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR ; COMPLETENESS OF RESPONSES OR RESULTS . ; MICROTREND SYSTEMS INC. DISCLAIMS ANY WARRANTY OF TITLE, ; QUIET ENJOYMENT,QUIET POSSESSION,AND NON-INFRINGEMENT OF ANY THIRD PARTY ; INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR ; YOUR USE OF THE PROGRAM.IN NO EVENT SHALL MICROTREND SYS. ; BE LIABLE FOR ANY SPECIAL, INCIDENTAL,CONSEQUENTIAL OR INDIRECT ; DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY AND WHETHER ; OR NOT MICROTREND SYS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH ; DAMAGES, ARISING IN ANY WAY OUT OF THIS AGREEMENT, THE PROGRAM, ; OR YOUR USE OF THE PROGRAM. EXCLUDED DAMAGES INCLUDE, BUT ARE NOT ; LIMITED TO, COST OF REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR ; COSTS, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF ; USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL MICROTREND SYS. ; AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF ; YOUR USE OF THE PROGRAM EXCEED FIVE (U.S.$5). ; Unless otherwise stated, the Program written ; by Microtrend Sys. is distributed as "freeware". You may, ; only under Microtrend Sys. copyright in the Program, use ; and modify the program without any charge or restriction. You may ; distribute to third parties, provided that you transfer a ; copy of this license to the third party and the third party ; agrees to these terms by its first use of the Program. You ; must reproduce the copyright notice and any other legend of ; ownership on each copy or partial copy, of the Program. ; You acknowledge and agree that the Program contains ; copyrighted material, trade secrets and other Microtrend Sys. ; proprietary information and is protected by copyright laws, ; international copyright treaties, and trade secret laws, as ; well as other intellectual property laws. ; ; ; ;****************************************************************************** ; This program creates a sinewave at the output of the DAC7513 D/A ; ; P2.0, P2.1 and P1.7 as control signals for DAC7513 ; on Microtrend Sys. Inc. MS-3003 platform ; Notice that there are two ways to modify sinewave frequency ; 1. Modify the software delay constant ; 2. modify the value written into SCFQCTL ;****************************************************************************** #include "msp430x43x.h" ; Standard Equations SYN equ 0080h SCLK equ 001h DIN equ 002h #define value R6 #define steps R7 ; RSEG UDATA0 RSEG CSTACK DS 0 RSEG CODE RESET mov #SFE(CSTACK),SP ; Initialize stackpointer StopWDT mov #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog ;mov.b #SELM_DCO,&FLL_CTL1; the CPU runs on DCO with these ; 3 instructions ;bis.b #DCOPLUS,&FLL_CTL0;comment them out if you want regular 1.048Mhz ;mov.b #100,&SCFQCTL ; D/A DAC7513 control pins assigned to P2.1 P2.0 and P1.7 bic.b #BIT7,&CAPD ;P1.7 bis.b #BIT0,&P2DIR ; P2.0 direction output bis.b #BIT1,&P2DIR ;P2.1 direction output bic.b #BIT7,&P1SEL ;p1.7 OUTPUT SELECT PORT NO COMPARATOR bis.b #BIT7,&P1DIR ;p1.7 DIRECTION output bis.b #SYN,&P1OUT ;p1.7 MAKE A ONE HERE initially on sync pin bic.b #BIT0,&P2OUT ; P2.0 direction output bic.b #BIT1,&P2OUT ;P2.1 direction output SetupADC12 mov #REFON+REF2_5V,&ADC12CTL0 ; ;we only need the 2.5V reference and the REFon mov #00010h,steps ; 16 steps mov #0,R8 ;R8 is a pointer to sinewave table again mov sinewave_table(R8),value call #sample call #Delay ; go to sample output routine inc R8 ; double increment for a word address inc R8 cmp #0020h,R8 ; are we done with 32 increments ? jnz again ; is one period over ? mov #0,R8 jmp again ; yes,start again ,do another period sample; this routine simulates an SPI interface mov #0010h,steps ; 16 steps beta nop nop bic.b #SYN,&P1OUT ;p1.7 OUTPUT MAKE A ONE HERE alfa rlc value jc shift_a_one shift_a_zero bis.b #SCLK,&P2OUT bic.b #DIN,&P2OUT ;P2.0 OUTPUT clear bic.b #SCLK,&P2OUT ;P2.1 OUTPUT jmp next shift_a_one bis.b #SCLK,&P2OUT bis.b #DIN,&P2OUT ;P2.0 OUTPUT set bic.b #SCLK,&P2OUT ;P2.1 OUTPUT next dec steps jnz alfa mov #0010h,steps ; 16 steps bis.b #SYN,&P1OUT ret sinewave_table dw 0x0000 dw 0x009a dw 0x0256 dw 0x04ef dw 0x7ff dw 0x0b0e dw 0x0da7 dw 0x0f63 dw 0x0fff dw 0x0f63 dw 0x0da7 dw 0x0b0e dw 0x07ff dw 0x04ef dw 0x0256 dw 0x009a Delay; Software delay push #011fh Dl1 dec.w 0(SP) jnz Dl1 incd SP ret ; ;------------------------------------------------------------------------------ ; Interrupt Vectors ;------------------------------------------------------------------------------ COMMON INTVEC ORG RESET_VECTOR ; MSP430 RESET Vector RESET_VEC DW RESET ; END