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
Youth deterent!
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Youth deterent!
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.
In v7 you need to capitalise the register name to work with the xc8 compiler.
Code: Select all
TMR0 = 0x195;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Youth deterent!
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
Deterrent will not work on hardware unless you change Clock source select within Interrupt properties from:
Code: Select all
Transition on T0CKI pin
Code: Select all
Internal clock.
Martin
Martin
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Youth deterent!
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
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Youth deterent!
Your welcome.
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
You have got that wrong!jgu1 wrote:TMR0 = 0x254;
Values are:
Decimal:
Code: Select all
TMR0 = 0;
Code: Select all
TMR0 = 255;
Hex:
Code: Select all
TMR0 = 0x0;
Code: Select all
TMR0 = 0xFF;
Martin
Martin