Timer1 Does not work

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Timer1 Does not work

Post by RABO2320 »

Hello
For RTC Clock:
Timer1 Clock Source 32.768khz Xtal Does not work
XX.png
XX.png (14.08 KiB) Viewed 6045 times
FLOW
Xtal32.768Khz.fcfx
(10.7 KiB) Downloaded 181 times
proteus
CLK.rar
(18.64 KiB) Downloaded 174 times

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

Have you tried this on real hardware or just inside the Proteus sim?

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hello Benj

I only tried it on proteus. :|

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Helloooooo Everyone :? :? :? :? :? :? :? :? :?

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

The setup is fairly straightforward and looks to be correct, could it be a Proteus sim problem? If you could try it on real hardware then that might give a much better indication.

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hello Ben

I tried it on real hardware.Unfortunately it did not work. :roll:

Also in the interrupt frequency section, interrupt frequency is created from the main source frequency. :?: :!: :?:

:arrow:
X1.png
X1.png (14.56 KiB) Viewed 5930 times
And files
Xtal32.768Khz.fcfx
(9.21 KiB) Downloaded 166 times
CLK2.rar
(18.11 KiB) Downloaded 180 times

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

Hmm the generated code does look ok, I've just compared it with the datasheet and I cant see any problems.

Can you send us a schematic of your current hardware setup so we can investigate what the problem might be. I tried your Proteus file but it isn't opening in my version.

Have you confirmed the chip is running, using a 1 second flasher test?

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hi ben

This is the schematic of my circuit:
:arrow:
1sec.PNG
1sec.PNG (191.14 KiB) Viewed 5886 times
:!: :!: :!:
I designed the same Flasher circuit for one second, but it didn't work

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

You have the configuration setup for an 20MHz external oscillator but this is not supplied on the schematic. First concentrate on this and getting the 1 second flasher running.

Next the crystal across the T1 pins needs capacitors to ground on both of the pins, datasheet specifies 33pf.
OSc.jpg
OSc.jpg (26.44 KiB) Viewed 5885 times

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hello Ben

I made the changes you mentioned(In real hardware), but nothing happened again :( :( :(
:arrow:
Capture.PNG
Capture.PNG (175.41 KiB) Viewed 5851 times
I acted according to the data sheet
:arrow:
1.PNG
1.PNG (209.91 KiB) Viewed 5851 times
:?:

But in interrupt settings, the interrupt frequency changes with clock speed change,That shouldn't be the case :?: :!: :?:
:arrow:
X1.png
X1.png (15.65 KiB) Viewed 5851 times

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

Is the one second flasher test now working? Nothing will work if this isn't working.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher

The interrupt properties interrupt frequency is wrong and is not calculated correctly. Its a bug that has been there for a while. It basically cannot know the frequency of your external input and so treats it as off the main clock. This can be ignored and won't cause any problems.

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hello Ben
Thanks for the reply.

The microcontroller works with the one-second flasher you provided,But I want to work with Clock Source 32,768 kHz(T1CKI/T1CKO).
I want to design a watch using the internal RTC microcontroller.
Can't this problem be solved? :?: :!: :?:

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,

Could it be your crystal at fault? Do you have a link to the crystal you are using so we can look at the specifications.

The code Flowcode is producing all looked ok to me but there could be something additional I am missing. I'll have another go through the datasheet just to try and be sure.

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hello Ben
.
I used 32.768khz crystal.
The crystal is perfectly healthy because I tested it in another circuit.I think the flowcode program code is incorrect. :idea: :idea: :idea:

User avatar
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: Timer1 Does not work

Post by Benj »

There are a few hints here that could help.
https://www.microchip.com/forums/m947335.aspx

I've looked at the code and it looks ok.

Maybe try setting the T1OSO pin (C0) to be an output by writing to the pin using an output icon before enabling the timer interrupt.

Maybe also try writing to the T1CON register yourself inside a c icon after enabling the interrupt to see if this helps.

Code: Select all

T1CON = 0x0B;
This should set 1:1 prescale, T1OSCEN enabled, TMR1CS External Clock, Enable Timer1

Maybe also try

Code: Select all

T1CON = 0x0F;
Which adds that the external clock sould be synchronised with the internal clock.

If all else fails maybe try a different crystal. The load capacitance/resistance of your crystal could be causing issues on the older 16F873A device.

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

hello ben

I used the codes you provided in the program,But again nothing happened and the hardware did not work.
:( :!: :?: :!:
T1CKI_T1CKO.fcfx
(9.08 KiB) Downloaded 134 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Timer1 Does not work

Post by QMESAR »

Hi.

Did you probe the XT pins with a scope to see what the XT signal looks like and it drive level???`
if so can you post the scope print !
if not then do it

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

hi...

I also tested with an oscilloscope,Crystal bases have no signal

Timer 1 does not work with the 32,768 clock source because I think the code has a problem.

:?: :?: :!: :!: :?: :?:

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hi Ben
please check it.

RABO2320
Posts: 41
Joined: Sun Mar 01, 2020 1:39 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Timer1 Does not work

Post by RABO2320 »

Hi

Please someone to guide

User avatar
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: Timer1 Does not work

Post by Benj »

Hello,
If all else fails maybe try a different crystal. The load capacitance/resistance of your crystal could be causing issues on the older 16F873A device.

Post Reply