Author Topic: April Fool’s Project!  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
April Fool’s Project!
« on: April 02, 2015, 12:14:29 am »
Hi Guys,
I wrote a pic program that can tell what oscillator frequency is clocking it.

Best quality video I could do to get it out for April Fools’ Day (UTC).
Cheers, Art.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: April Fool’s Project!
« Reply #1 on: April 02, 2015, 12:31:51 am »
I assume you are using the internal WDT timer timeout to determine the clock speed.

Start Timer 1 on powerup, Wait for a WDT reset. 
If it was a WDT reset skip the above, read timer 1 to get the speed  then, knowing that your clock speeds are separated by more that the 40% WDT clock error simply pick the closest known speed to calibrate your delays which must keep 'kicking the dog' with the CLRWDT instruction.
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Re: April Fool’s Project!
« Reply #2 on: April 02, 2015, 12:45:12 am »
Wow this paid off :) Your way might be better than mine.

BUT is the timer1 value not reset with he WDT so you could not read the timer values after reset?

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: April Fool’s Project!
« Reply #3 on: April 02, 2015, 01:11:34 am »
No. see datasheet DS40044G section 7.6
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1059
Re: April Fool’s Project!
« Reply #4 on: April 02, 2015, 01:28:13 am »
Ok, I’m busted. I was a lot more sloppy, you will not like it :D

Make a fixed delay that will vary with clock speed,
run that delay in a loop that also writes a zero byte to on-chip EEPROM and increments the address,
The watchdog resets before it can fill the 256 bytes of EEPROM.
Then after reset count the number of zero values on the EEPROM,
write all 0xFF values to EEPROM for the next startup and go from there.

I appreciate your input.
I want to add a toggle flip flop to this for a few more frequencies and use the code in a bigger project.





 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf