Can not write TIMER1_CTRL_REG

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at https://www.dialog-semiconductor.com/support . We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
lecarter190
Offline
Last seen: 1 year 6 months ago
Joined: 2020-02-27 18:00
Can not write TIMER1_CTRL_REG

Hi,

I am modifying the barebones example using the PRO development board and the DA14531MOD daughterboard.

I've tried to attach a screen shot of the problem but can not figure out how.   I am trying to write to the TIMER1_CTRL_REG using SetWord32(TIMER1_CTRL_REG,value) where value = 0x126400.  The Disassembly window shows instruction STR r0,[r1,#0x00] where R0 = 0x00012640 abd R1 = 0x50004000.   But memory location 0x50004000 does not change from 0.

When I run this command, memory location 0x50004000 remains 0 and the timer does not run when enabled.   I also tried value = 0x1A640, choosing the sys clk.

I would appreciate any insight into why the register does not change when written to.

Thanks,

Larry

 

Device: 
MHv_Dialog
Offline
Last seen: 1 year 2 months ago
Staff
Joined: 2013-12-06 15:10
Hi Larry,

Hi Larry,

You appear to try to write 32 bits to a 16 bit wide register (see table 342 of the datasheet for details). Try using SetWord16() instead ;o)

Writing directly to registers of the DA14531 is rarely the best way to achieve anything. Please take a look at the peripheral_examples folder of the SDK for examples that demonstrates use of the the timers.

You may also have a look at how you can use app_easy_timer (emphasis on EASY) - check section 9 of the "Getting Started with SDK6" tutorial: http://lpccs-docs.dialog-semiconductor.com/Tutorial_SDK6/index.html 

/MHv

lecarter190
Offline
Last seen: 1 year 6 months ago
Joined: 2020-02-27 18:00
Thank you for your response

Thank you for your response however, the register is 17 bits and the FW in the sdk_driver:timer1.c uses SetWord32.  I had also tried to write only to the lower 16 bits with the same results.

the following is right out of timer1.c for your reference.

void timer1_count_config(timer1_count_options_t *count_options, timer1_count_handler_t callback)
{
    ASSERT_WARNING(count_options->reload_val <= TIM1_RELOAD_MAX);

    uint32_t temp = (count_options->input_clk << 15u) + (count_options->free_run << 14u) +
                    (count_options->irq_mask << 13u) + (count_options->count_dir << 12u) +
                    (count_options->reload_val);

    /* Reset the current timer value. */
    // NOTE: The following operation sequence shall not change!!
    SetBits32(TIMER1_CTRL_REG, TIMER1_CLK_EN, TIM1_CLK_ON);
    SetBits32(TIMER1_CTRL_REG, TIMER1_USE_SYS_CLK, TIM1_CLK_SRC_SYS);
    SetBits32(TIMER1_CTRL_REG, TIMER1_COUNT_DOWN_EN, count_options->count_dir);
    SetBits32(TIMER1_CTRL_REG, TIMER1_ENABLE, TIM1_OFF);

    /* Write the provided configuration. */
    SetWord32(TIMER1_CTRL_REG, temp);

    /* Register the provided callback. */
    timer1_count_register_callback(callback);
}

I can not use easy timer, I need resolutions much finer than 10 mS.

The peripheral_examples folder does not show how to use timer1, only timer 0 and 2 as far as I found.

I prefer to write directly to the registers for many reasons, I do refer to the sdk_driver code you provide which writes directly to the registers.

The problem boils down to the instuction I referenced in my original post which was ---The Disassembly window shows instruction STR r0,[r1,#0x00] where R0 = 0x00012640 and R1 = 0x50004000.   But memory location 0x50004000 does not change from 0.

Is there any memeory protection or such that would prevent a 16 bit or 32 bit write to that memory location?

Larry

 

 

lecarter190
Offline
Last seen: 1 year 6 months ago
Joined: 2020-02-27 18:00
Looking at Figure 10 of the

Looking at Figure 10 of the datasheet, it appears that Timer1 is in a different domain than the timers 0 and 2.   Is it possible in the barebones example that power is off to Timer1?   If so, where and how do I turn it on in that example?

Thanks,

Larry

lecarter190
Offline
Last seen: 1 year 6 months ago
Joined: 2020-02-27 18:00
Got it, needed to clear the

Got it, needed to clear the TIM_SLEEP bit in PMU_CTRL_REG

Larry