Could someone please, give a working example on how to setup and run the timer interrupt for C54x?
This is sooooo hard to figure out on my own.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Could someone please, give a working example on how to setup and run the timer interrupt for C54x?
This is sooooo hard to figure out on my own.
Hello
First, thank you fror your help. I'm about to deliver a project and I can't even setup the timer correctly. I'm usign a TMS320VC5401. I need to setup the timer at 48kHz. In the timer interrupt routine I put a RSBX XF to clear the flag (the XF pin is connected to a LED so I can see it). From what I read, the inital state of the pin is SET, so the LED is on in my board. My test is that when the processor enters in the timer ISR the LED should go off.
The problem is that it is not going off and I don't know what to do.
Hello
Thanks for your help.
I get the timer working. The problem was a poorly written manual and my wrong understanding of how the interrupt vectors work.
Now I have another problem. I have a buffer of samples which should be played and I put this buffer hardcoded in the code. The buffer should be played at 48khz. The 48khz int is working.
The problem is that I'm getting the wrong values played. When it runs, seems that the pointer pass the memory and plays stuff that it should not do.
Check the code (partial). Could you please help me?
-----------------------------------------------------------------
; ============================================================================================================================
.SECT "CodeLivesHere"
.GLOBAL CodeStart ; This makes CodeStart global so I can add it as entry point for the code in link command file
.mmregs
; ============================================================================================================================
SWCR .SET 0x002B ; Software wait-state control register External Bus (this does net gets included using .mmregs)
LeftChannel .SET 0x0001 ; DAC Left Channel
RightChannel .SET 0x0002 ; DAC Right Channel
; ============================================================================================================================
IntVectors:
B CodeStart
NOP
NOP
B NonMskInt
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
B Timer0Int
NOP
NOP
NOP
NOP
; ==============================================================================================================================
CodeStart: ; Let the fun begin ! ---------------------------------------------------------------------------------
STM #29FFh, SP ; Set stack pointer
SSBX XF ; Turn LED on
InitCode: ; Set internal registers ------------------------------------------------------------------------------
STM #1028h, PMST ; Interrupt vectors location, MC mode, overlay+DROM enabled
XOR A, A
XOR B, B
LD #0, DP
STLM A, XPC ; All code runs inside the DSP
STLM A, SWWSR ; Software wait-state register External Bus
STLM A, SWCR ; Wait states are not multiplied by 2
STLM A, BSCR ; No mask, no additional cycle between reads
LD #0, A
STLM A, AR1
PSHM AR1
PSHM AR1
PSHM AR1
PSHM AR1
PSHM AR1
POPM AR1
POPM AR1
POPM AR1
POPM AR1
POPM AR1
; Timers -------------------------------------------------------
STM #01F7h, TCR ; Stop timer and set periods
STM #007Fh, PRD ; Set timer period
STM #01E7h, TCR ; Reload periods and start timer
; Variables ----------------------------------------------------
; Interrupts ---------------------------------------------------
STM #0FFFFh, IFR ; Acknowledge all interrupts
STM #0008h, IMR ; Enable all necessary ints
RSBX INTM ; Enable All Interrupts
; Buffers ------------------------------------------------------
STM sample_data_start, AR0 ; AR0 points to the start of the samples buffer
; Main loop ----------------------------------------------------
MainCode: ; All funstuff happens here
NOP
B MainCode
; Timer0 isr --------------------------------------------------
Timer0Int: ; 48KHz Timer
STM #0008h, IFR ; Acknowledge all interrupts
; writes sample to the left channel
PORTW *AR0, LeftChannel
; writes sample to the right channel and increments AR0
PORTW *AR0+, RightChannel
; increments counter
ADD B, 1
; copies from B to A
LD B, A
; aubtracts A from the value we want to compare
SUB #1546, A
; if A < 1546 then goto end of ISR
BC Timer0Int_end, ALT
; AR0 points to the start of the samples buffer
STM sample_data_start, AR0
; resets counters
XOR A, A
XOR B, B
Timer0Int_end:
RETE
NonMskInt:
RETE
sample_data_start .word 0x800
.word 0x7F0
.word 0x750
.word 0x660
.word 0x790
<< lots of samples here >>
.word 0x810
.word 0x800
.word 0x7F0
.word 0x7F0
.word 0x810
.word 0x800
.word 0x800
.word 0x810
.word 0x800
.word 0x800
.word 0x800
.word 0x800
.word 0x800
.word 0x800
sample_data_end .word 0x0
; ==============================================================================================================================
.END
; ==============================================================================================================================