Help on C24x

Help on C24x

Post by Jerom » Wed, 10 Mar 1999 04:00:00



Hi,ALL,
I am a student using C24x to construct a general motion control system. May
I ask anyone have sample program(in C or assemble) include
initilization,read A/D channal and write output to D/A? I need this program
ungently. Very appreciate your help.

Jerome

 
 
 

Help on C24x

Post by Paul Taylo » Thu, 11 Mar 1999 04:00:00


Have you downloaded the .pdf app notes from www.ti.com ?
(maybe enter TMS320F240 and see what their search shows).

>Hi,ALL,
>I am a student using C24x to construct a general motion control system. May
>I ask anyone have sample program(in C or assemble) include
>initilization,read A/D channal and write output to D/A? I need this program
>ungently. Very appreciate your help.

>Jerome


 
 
 

Help on C24x

Post by brian_he.. » Fri, 12 Mar 1999 04:00:00


Today is your lucky day.  Here's ADC and DAC code to work on the F240 EVM
board from TI or from Spectrum Digital.  You'll need to edit it for your
application but it should give the essentials.

For initialization you'll need to download code from TI's web site and
customize it for your application.  If I gave you my initialization code
it would probably confuse you more than help you.

Good Luck

Brian Heber
Sr. Design Engineer
Liebert Power R&D

*******************************************************************************
*                    ADC Stuff                                                *
*******************************************************************************
                .def    _GetFirstA2D
                .def    _EndOfConversionISR

                .def    ADstate
                .bss    ADstate,1,1

  .text
;============================================================================
== ; Public Method:  GetFirstA2D()  45 cycles
;============================================================================
== _GetFirstA2D:  setc  sxm

        larp    AR3
        lar     AR3,#ADCTRL1

WAIT_EOC_1:
        bit     *, 8              ; Test BIT 7 (EndOfConversion Flag)
        bcnd    WAIT_EOC_1,TC

        lar     AR3,#ADCFIFO1
        lacl    *
        sub     #32736            ; Convert to Q15. 10b-ADC so 0xFFC0 = 5v
        ldp     #Signal0          ; Want 2.5v = 0 (Q15) so sub 1 (32768-32)
        sacl    Signal0           ; 0v = 0x8020, 2.5v = 0x0, 5v = 0x7FE0

        lar     AR3,#ADCFIFO2
        lacl    *
        ldp     #Signal1
        sacl    Signal1                 ; Unsigned number

        ldp     #_ADstate
        lacc    #1
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels, start conversion & enable EOC interrupt

  ldp  #SYS_PAGE  ;  splk  #0DB24h,ADCTRL1  ; Set Mux Lines: CH2 & CH 10
splk  #0FB24h,ADCTRL1  ; Start Conversion NOW! BIT 13  ret
;============================================================================
== ; Public Method:  EndOfConversionISR()
;============================================================================
== _EndOfConversionISR:  setc  sxm  larp  AR3

        ldp     #_ADstate
        lacc    _ADstate
        sub     #1
        bcnd    SAMPLE2,EQ              ; If _ADstate == 1 goto SAMPLE2
        sub     #1
        bcnd    SAMPLE3,EQ              ; Else If _ADstate == 2 goto SAMPLE3
        sub     #1
        bcnd    SAMPLE4,EQ              ; Else If _ADstate == 3 goto SAMPLE4
        sub     #1
        bcnd    SAMPLE5,EQ              ; Else If _ADstate == 4 goto SAMPLE5
                                        ; Else _ADstate == 5 goto SAMPLE6
;____________________________________________________________________________
SAMPLE6:
        larp    AR3
        lar     AR3,#ADCFIFO1
        lacl    *                       ;
        ldp     #Signal9                ;
        sacl    Signal9                 ;
                                        ;

        lar     AR3,#ADCFIFO2
        lacl    *                       ; Clear FIFO2

        ldp     #_ADstate
        lacc    #6
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels & disable EOC interrupt
        ldp     #SYS_PAGE               ; Disable EOC interrupt
        splk    #0D932h,ADCTRL1         ; MUX set for ADCIN1 & ADCIN11

        b       EOC_DONE
;____________________________________________________________________________
SAMPLE5:
        larp    AR3
        lar     AR3,#ADCFIFO1
        lacl    *
        sub     #32736            ; Convert to Q15. 10b-ADC so 0xFFC0 = 5v
        ldp     #Signal7          ; Want 2.5v = 0 (Q15) so sub 1 (32768-32)
        sacl    Signal7           ; 0v = 0x8020, 2.5v = 0x0, 5v = 0x7FE0

        lar     AR3,#ADCFIFO2
        lacl    *
        sub     #32736                  ; Convert to Q15
        ldp     #Signal8
        sacl    Signal8

        ldp     #_ADstate
        lacc    #5
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels, start conversion & enable EOC interrupt
        ldp     #SYS_PAGE               ;
        splk    #0DB6Ah,ADCTRL1         ; Set Mux Lines: CH5 & Don't Care
        splk    #0FB6Ah,ADCTRL1         ; Start Conversion NOW! BIT 13
        b       EOC_DONE
;____________________________________________________________________________
SAMPLE4:
        larp    AR3
        lar     AR3,#ADCFIFO1
        lacl    *
        sub     #32736            ; Convert to Q15. 10b-ADC so 0xFFC0 = 5v
        ldp     #Signal5          ; Want 2.5v = 0 (Q15) so sub 1 (32768-32)
        sacl    Signal5           ; 0v = 0x8020, 2.5v = 0x0, 5v = 0x7FE0

        lar     AR3,#ADCFIFO2
        lacl    *
        sub     #32736                  ; Convert to Q15
        ldp     #Signal6
        sacl    Signal6

        ldp     #_ADstate
        lacc    #4
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels, start conversion & enable EOC interrupt
        ldp     #SYS_PAGE               ;
        splk    #0DB6Ch,ADCTRL1         ; Set Mux Lines: CH6 & CH14
        splk    #0FB6Ch,ADCTRL1         ; Start Conversion NOW! BIT 13
        b       EOC_DONE
;____________________________________________________________________________
SAMPLE3:
        larp    AR3
        lar     AR3,#ADCFIFO1
        lacl    *
        ldp     #Signal4
        sacl    Signal4                 ; Unsigned number

        lar     AR3,#ADCFIFO2
        lacl    *                       ; Clear FIFO2

        ldp     #_ADstate
        lacc    #3
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels, start conversion & enable EOC interrupt
        ldp     #SYS_PAGE               ;
        splk    #0DB7Eh,ADCTRL1         ; Set Mux Lines: CH7 & CH15
        splk    #0FB7Eh,ADCTRL1         ; Start Conversion NOW! BIT 13
        b       EOC_DONE
;____________________________________________________________________________
SAMPLE2:
        larp    AR3
        lar     AR3,#ADCFIFO1
        lacl    *
        sub     #32736             ; Convert to Q15. 10b-ADC so 0xFFC0 = 5v
        ldp     #Signal2           ; Want 2.5v = 0 (Q15) so sub 1 (32768-32)
        sacl    Signal2            ; 0v = 0x8020, 2.5v = 0x0, 5v = 0x7FE0

        lar     AR3,#ADCFIFO2
        lacl    *
        sub     #32736                  ; Convert to Q15
        ldp     #Signal3
        sacl    Signal3

        ldp     #_ADstate
        lacc    #2
        sacl    _ADstate                ; Increment _ADstate

; Now configure the next A/D channels, start conversion & enable EOC
interrupt  ldp  #SYS_PAGE  ;  splk  #0DB36h,ADCTRL1  ; Set Mux Lines: CH3 &
Don't Care  splk  #0FB36h,ADCTRL1  ; Start Conversion NOW! BIT 13 EOC_DONE:
ret
;____________________________________________________________________________
__  .end  ; End EVM_ADC.ASM

*******************************************************************************
*                    DAC Stuff                                                *
*******************************************************************************
;------------------------------------------------------------------------------
; Constants
DAC0            .set    000             ; DAC I/O Mapped output #1
DAC1            .set    001             ; DAC I/O Mapped output #2
DAC2            .set    002             ; DAC I/O Mapped output #3
DAC3            .set    003             ; DAC I/O Mapped output #4
DAC_UPDATE      .set    004             ; Start D2A conversion
;------------------------------------------------------------------------------
; External Methods
;------------------------------------------------------------------------------
; External Attributes
                .ref    Signal0
                .ref    Signal1
                .ref    Signal2
                .ref    Signal3
;------------------------------------------------------------------------------
; Public Methods
                .def    _InitDAC        ; Initialize the DAC
                .def    _UpdateDAC      ; Output digital signals to the DAC
;------------------------------------------------------------------------------
; Public Variables
;------------------------------------------------------------------------------
; Local Variables
                .bss    localDAC,5,1    ; Temp RAM location
DAC_out0        .set    localDAC+1      ; Digital to Analog output #0
DAC_out1        .set    localDAC+2      ; Digital to Analog output #1
DAC_out2        .set    localDAC+3      ; Digital to Analog output #2
DAC_out3        .set    localDAC+4      ; Digital to Analog output #3

  .text
;============================================================================
== ; Begin Public Method:  InitDAC()
;============================================================================
== _InitDAC: ; Now initialize the Digital to Analog registers ; The DAC
module requires that wait states be generated for proper operation.  ldp
#localDAC  ; DP for address 0000h-007Fh, B2  splk  #4h,localDAC  ; Set Wait
State Generator for  out  localDAC,WSGR  ; Program Space, 0 wait states  ;
Data Space, 0 wait states  ; I/O Space, 1 wait state  ret
;============================================================================
== ; Begin Public Method:  UpdateDAC()
;============================================================================
== _UpdateDAC:  setc  sxm ; UniPolar 12bit DAC: 0x0000 = 0V, 0x07FF = 2.5V,
0x0FFF = 5.0V (unsigned) ; Convert signed 16bit number to unsigend 12bit
number. ;  unsigned_12bit = (signed_16bit/16) + 2^(12-1) = (signed_16bit/16)
+ 2048 ;  exa:  32767/16 + 2048 = 4095 = 0x0FFF (5.0000V DAC output) ;
16384/16 + 2048 = 3072 = 0x0C00 (3.7509V DAC output) ;  00000/16 + 2048 =
2048 = 0x0800 (2.5006V DAC output) ;  -16384/16 + 2048 = 1024 = 0x0400
(1.2503V DAC output) ;  -32768/16 + 2048 = 0000 =
...

read more »

 
 
 

1. TI C24x COFF to DSK converter utility required

Does anybody know of, or have, a DOS command-line utility for converting TI
C-compiler .OUT files to .DSK format for the C24x DSK?

I have a customer who is in need of such a utility and have drawn a blank
with TI. (They have a Windows-based program to do this, but the customer is
using Linux and wants to avoid using the Linux Windows emulator).

Many thanks,
Paul Bolderson.
Kane Computing.


(remove the Upper Case letters)

2. Yamaha QY70 & Emu Proteus 2000 questions

3. TMS320C32 vs C24x

4. Vuescan 7.6.35 IR and FS4000 US problem

5. Help with VDSP++ 1.0 Help

6. Editor emulation no longer supported?

7. Help a Newbie to Help Himself

8. Macromedia Director 7

9. Help!!! beginner help TMS320F243

10. Help CELP Help CELP!

11. HELP!!!!! I need help!!!!!!!

12. help help

13. HELP!! HELP!! IEC electroacoustical standards