TL;DR When adjusting parameters in the MPLab IDE's Code Configurator (MCC) then simply saving the settings is not enough, you MUST hit Generate to recreate the generated config files
---
I my previous videos about this module I'd made a comment about the displays not being that fast however, the 75Hz display refresh rate was irritating me because it flickers in the camera but also because I was frustrated that the numbers I was seeing just didn't add up.
I was convinced that I had the clock set to 4MHz and that should have been plenty fast to avoid flicker but I didn't have the data to prove it.
Double check ..
- I verified the refresh rate again by measuring the frequency of the common cathode line as being about 75Hz.
- Disassembling my program I counted approx 900 instructions per loop.
- The PIC does one instruction per 4 clock cycles so at a 4MHz clock I ought to be getting 1m instructions per sec.
- Loops per sec = 1m inst per sec / 900 instructions = 1100
.... so I should be seeing sometihng like 1100 loops per second; therefore approx 1100 refreshes per second.
? 75Hz is a long way off.
I then noticed that the system.h generated file had a "#define SYS_FREQ 250000".
Putting these numbers back into the equation ...
- Loops per sec = (250000/4) / 900 = 69Hz ; which was close enough to the measured 75Hz for me to be sure I was on the right track. The chip was actualy running at 250k/4=62.5KHz
I checked back on the settings in the MPLab IDE and it was definitely saying 4MHz. .. so confused.
A few hours later, and really annoyed, I realised that it had been so long since I'd used the IDE that I I'd forgotten that changing the settings in the MPLab Code Configurator (MCC) alone isn't enough to make the MCC settings take effect, and I also had to clock the "Generate" button. My PIC's had been running at 250KHz for weeks and not MHz. Having done the Generate the same file was updated to "SYS_FREQ 4000000".
Outcome
- Refresh rate is now approx 600Hz , and with the extra clock speed I was able to add a little program tweak to add a bit more sleep to the loop now the displays are a little brighter too.
All files pushed to https://github.com/Johnlon/SevenSegmentModule
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.