Write to Flash upsets clock frequency

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

After much debugging, I've finally stumbled upon what was causing parts of my code to not operate correctly all of the time.  It seems that when I write to flash on my 4100 BLE chip, it was causing two issues:

   

1.  For a brief period after the write to flash, my UART TX/RX was getting screwed up and I was seeing a buch of gibberish on my terminal screen.  I believe this was because the clock driving the UART, which is derived from the HFCLK, was being impacted, which meant my baud rate was out of whack briefly

   

2.  Also, for a brief period after the write to flash, my PWM signal, which was also driven off a clock signal derived from the HFCLK, was in turbo mode and seemed to be operating at about 10 times the frequency I was wanting it to.

   

In both cases, my HFCLK was derived from the IMO.

   

Is this sort of behaviour to be expected when writing to flahs?  I'm not sure how stable the IMO is supposed to be and what's the best way to get around it.  In the short term I'm just shifting my write to flash code to a point in time where the UART and PWM aren't being used, or aren't critical to operation of the hardware, but I'd like to understand what the root cause is and how I can get around it.

   

Can anyone provide any comments/advice?

   

Cheers,

   

Mike

0 Likes
1 Solution
AnWa_1259496
Level 4
Level 4
Welcome! 50 replies posted 25 replies posted

I spent ages on this also.

   

The example project which contains a function for writing to SFlash, "WriteUserSflash.c" does not leave the clocks in the same state which messes everything up after its been run.

   

In the end I re-run the whole of the clock initialization which is contained within Cyfitter_cfg.c after each flash write.

View solution in original post

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Mike, have a look into the "System Reference Guide" (Creator Help menu) to get descriptions which clocks and devices are affected by a flash write.

   

 

   

Bob

0 Likes
AnWa_1259496
Level 4
Level 4
Welcome! 50 replies posted 25 replies posted

I spent ages on this also.

   

The example project which contains a function for writing to SFlash, "WriteUserSflash.c" does not leave the clocks in the same state which messes everything up after its been run.

   

In the end I re-run the whole of the clock initialization which is contained within Cyfitter_cfg.c after each flash write.

0 Likes