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.

Change clock settings when required

Hi all,

I am working on an application where i need to maintain 32MHz clock all the time in my peripheral device. I have called following function in SimpleBLEPeripheral_Main.c just before osal_start_system() is called in main().

void initialise(void)
{
      // Set system clock source to HS XOSC, with no pre-scaling.
    CLKCONCMD = (CLKCONCMD & ~(CLKCON_OSC | CLKCON_CLKSPD)) | CLKCON_CLKSPD_32M;
    // Wait until clock source has changed.
    while (CLKCONSTA & CLKCON_OSC);
 }

Since i am calling above function after HAL_BOARD_INIT(), it should overwrite the initial clock settings. I have disabled POWER_SAVING. Even after calling above function the clock changes. I am using SimpleBLEPeripheral project.

1)How can i maintain 32MHz clock setting all the time.

2)If i am processing for loop for longer time(10sec suppose), will osal event(set for 5sec) occur then also to process the osal event and come back again to process the for loop? 

Thanks

  • Hello,

    Why is 32M needed all the time? The Stack is designed to only enable the clock when needed (BLE RF).

    Best wishes
  • Hi,
    Sorry, i didn't mention clearly. I don't need 32M clock all the time. Actually i am using timer3 in modulo mode for recording voice in external flash and playing it back to DAC through SPI. So when i need to write or read through SPI, i need system clock to be 32M. Rest of the time i can change the clock setting to be original or disable when needed. This recording or playing will be done 4-5 times a day and will last for 30sec. so during this time i require 32M clock to operate. What i have realized is my "for loop" ends very faster and my actual record interval is 30sec but it lasts just 8-10sec and voice quality gets disturbed(reduced).
    So can anyone please suggest how can i proceed with this requirement. Power consumption is secondary concern for now for me. I will think for optimizing it for reducing power consumption later.
    Thanks
  • Hi,
    1)Is it possible to proceed with my requirements as mentioned in my previous post? Is it going to affect if i reset the clock speed and timer3 as required when i am recording and playing and rest of the time i use same clock as used by stack?
    2)What i need to do to maintain the existing clock used by BLE stack after i have finished my recording and playing message? I will change clock speed as specified by stack after i have done my process.
    Thanks