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.

C5401 - timer



Hello, people.

I have desgined a board around the C5401 DSP. I'm trying to run a simple timer at 48kHz and read the output in the TOUT pin with the scope. The problem is that the pin shows nothing. I'm posting the code I'm using to init and run the timer.

If I'm correct this code should, at least, toogle TOUT pin (pin 82 in my IC) with a frequency of 48kHz. Do I have to setup some other stuff (maybe some general propose IO setting) for the pin to toogle? It seems it is in HIGH-Z state.

Thank you.

---------------CODE------------------------------------

main:
STM #3FFFh, IFR ; Mask off all interrupts
STM #2FFEh, SP ; Set stack pointer

; Set internal registers
STM #7FFFh, 0028h ; Wait state things (default value)

; initializes accumulators
LD #0000, A

; init timer
CALL init48kHzTimer0

; loop for the main routine
mainLoop:

; branches to mainLoop
B mainLoop

init48kHzTimer0:

; loads A with 0x0000
LD #0000h, A

; loads the value of TCR in A
LDM TCR, A

;enables TSS bit (stops the timer)
OR #0010h, A

; loads TCR with the value of A
STLM A, TCR

; loads A with 0x7F (127 decimal)
LD #007Fh, A

; loads PRD with the value of A
STLM A, PRD

; loads A with 0x0000
LD #0000h, A

; loads the value of IMR in A
LDM IMR, A

; writes 1 to the 4th bit (Timer int) in IMR (without messing other bits)
OR 0x0008, A

; loads IMR with the value of A
STLM A, IMR

; loads A with 0x0000
LD #0000h, A

; loads the value of TCR in A
LDM TCR, A

; loads TDDR with 0x0007 and TRB with 1
OR 0x0027, A

; loads TCR with the value of A (starts the timer)
STLM A, TCR

RETE

---------------END CODE------------------------------------

  • What is the value of OFF?

    Regards.

  • According to the schematic:

    EMU1/OFF is tied to VCC

    /TSRT is tied to GND

    EMU0 is tied to GND

    Is this setup OK?

  • OK

    I know that, according to the datasheet, this setup won't work for the TOUT pin. But the timer should be working. I'm using this code to setup a 48kHz timer. But it is getting a 6.6us cycle (3x faster).

    My setup routine is:

    ----------------------------------------------------------------------------------------------------------------------------

    init48kHzTimer0:

    ; loads A with 0x0000
    LD #0000h, A

    ; loads the value of TCR in A
    LDM TCR, A

    ;enables TSS bit (stops the timer)
    OR #0010h, A

    ; loads TCR with the value of A
    STLM A, TCR

    ; loads A with 0x7F (127 decimal)
    LD #007Fh, A

    ; loads PRD with the value of A
    STLM A, PRD

    ; loads A with 0x0000
    LD #0000h, A

    ; loads the value of IMR in A
    LDM IMR, A

    ; writes 1 to the 4th bit (Timer0 int) in IMR (without messing other bits)
    OR 0x0008, A

    ; loads IMR with the value of A
    STLM A, IMR

    ; loads A with 0x0000
    LD #0000h, A

    ; loads the value of TCR in A
    LDM TCR, A

    ; loads TDDR with 0x0007 and TRB with 1
    OR 0x0027, A

    ; loads TCR with the value of A (starts the timer)
    STLM A, TCR

    RETE

    ----------------------------------------------------------------------------------------------------------------------------