What commands affected by 16Mhz Resonator on 28X1 chip.?

Craftybytes

Senior Member
As the title says - what commands will be affected if I run my 28X1 on 16Mhz resonator.?

I've had a read of the Picaxe manuals - but am still unsure as to actual commands that will be effected AND what the effect will be.?

For example - can I still use i2cwrite / i2cread commands correctly at 16Mhz clock or do I need to use the 'setfreq M8' command first then do a return to 'setfreq M16' after any relevant code block.?

Or can I even use the 'setfreq' command if I'm using a 16Mhz resonator clock speed.?

Or is it just a case of being more careful of changed 'timings' with respect to some of the commands that may be affected.?

Any help much appreciated.

TIA.

crafty.
.
 

BCJKiwi

Senior Member
Manual2;
Firstly there is the directive freq - syntax #freq. See directives at the beginning of the manual AND also in the setfreq command. A directive is used in the header at the beginning of the program.

setfreq is an in-line command allowing change of speed within the program.
The explanation on page 160 is as good as you get in one place. Other commands that are affected have that noted within the information for that command.
If you search the manual for clock speed, you see all the affected commands - some 40 odd references.
The number representing the speed is (for example) m8 for internal or em8 for external resonators.

i2c is not affected as the (h)i2csetup command specifies the bus speed.
 

Craftybytes

Senior Member
Thanks BCJKiwi..

Had not thought of searching the manual for 'clock speed' - good call..

BTW - where in the manual will I find reference to the '(h)i2csetup' or (h)i2cxxxxx' commands - or is there any external references..?

Much appreciated.

crafty.
.
 

Craftybytes

Senior Member
Ok - found I didn't have the latest copies of the manuals - now fixed..

So can now find references to '(h)i2csetup' and other relevant 'i2c' commands - now to work out my code for my "i2c" side of my project.

Thanks for the help..

crafty.
.
 

Technical

Technical Support
Staff member
On X1 parts where 4MHz timing is absolutely essential - e.g. using a readtemp or other 1-wire command - the bootstrap will automatically drop to internal 4MHz, execute the command, and then return to the original external set frequency. So the operating frequency in these cases is irrelevant and the command will always work.

However this does not apply to i2c commands, because there are separate constants to set the i2c bus speed at different frequencies.
 

westaust55

Moderator
On X1 parts where 4MHz timing is absolutely essential - e.g. using a readtemp or other 1-wire command - the bootstrap will automatically drop to internal 4MHz, execute the command, and then return to the original external set frequency. So the operating frequency in these cases is irrelevant and the command will always work.

However this does not apply to i2c commands, because there are separate constants to set the i2c bus speed at different frequencies.
Maybe time to add a further clarification to manual 2 about the effects of clock frequency.
Could also add some words about input0-input7 and output0-output7.
For example that input0 is a synonym for pin0
 

Technical

Technical Support
Staff member
So what would happen to PWMout and servo when a command such as Readtemp is executed?
readtemp on the 28X1 will only work at 4MHz, due to the very specific 1-wire timing requirements. So to use servo and readtemp in the same program on a 28X1 there are only two available options:

a) run every thing at 4MHz, then no problems anywhere
b) run at 16MHz but temporarily drop down to 4MHz for the actual readtemp command.

As explained under readtemp command in part 2 of the manual the readtemp command does this 4MHz drop automatically if you are not already using 4MHz - this reduces code size (and speeds up the change) as the user then does not have to type in two extra setfreq commands.
 

BeanieBots

Moderator
I assume from Technical's reply that for the duration of readtemp (about 750mS) that the background tasks (servo, PWMout) will run as if you executed a setfreq command of 4Mhz. ie half the rate if you were at 8Mhz.
I can't play with my 18Xs at the moment:mad: so will try and give it a go on 28X1 to see.
 
Top