Page 1 of 1
Youth deterent!
Posted: Tue Feb 20, 2018 5:39 pm
by jgu1
Hi!
I am trying to create/convert the "youth deterent" from Bert v Dam´s book from FC5 to FC7. But when I compile the program I get "error code 1"
and it have something to do with tmr0, I use the C command: tmr0=0x195;
It work in FC5 but not in FC7. Can anybody tell me what I am doing wrong please?
Br Jorgen
Re: Youth deterent!
Posted: Tue Feb 20, 2018 6:05 pm
by Benj
Hi Jorgen,
In v7 you need to capitalise the register name to work with the xc8 compiler.
Also your value looks wrong, should this be 195 instead of 0x195? 0x195 is a 12-bit value and the TMR0 regiser is an 8-bit register.
Re: Youth deterent!
Posted: Tue Feb 20, 2018 6:33 pm
by jgu1
Hi Ben!
Thank´s again for REALLY fast reply. And it work.
Br Jorgen
Re: Youth deterent!
Posted: Tue Feb 20, 2018 6:42 pm
by medelec35
Hi Jorgen,
Deterrent will not work on hardware unless you change Clock source select within Interrupt properties from:
to
Otherwise intrerrupt will be waiting for a change on T0CKI pin.
Martin
Re: Youth deterent!
Posted: Tue Feb 20, 2018 8:02 pm
by jgu1
Hi Martin!
No I see now when you spotted this, of course, thank´s. I have to test it later on hardware. I could not understand why I not was able to compile.
My goal is, to create random frequencies from16Khz to 40Khz in approx. 2-3 kHz step. I have to measure how high the freq is if I set TIM0 to:
TMR0 = 0x254;
Thank´s Martin for spotting.
Br Jorgen
Re: Youth deterent!
Posted: Tue Feb 20, 2018 9:25 pm
by medelec35
Your welcome.
jgu1 wrote:TMR0 = 0x254;
You have got that wrong!
Values are:
Decimal:
to
or
Hex:
to
Although in practice you would not go too near the highest value of dec 255 or hex 0xFF
Martin