Timer problems PIC18LF14K50

Any bugs you encounter with Flowcode should be discussed here.
electronick
Posts: 13
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Timer problems PIC18LF14K50

Post by electronick »

Hi all.
Chip: PIC18LF14K50
I have confirmed the chip speed settings and I/O functions, and they work OK.
USB serial also works after putting an external pull up on D+ pin.

So my problems with this chip continues with its timers.
This chip has 4 timers(0-3) and if I start a new project and test these timers, one by one, by simply incrementing a variable, using the internal clock, all works fine as its supposed to.
If I set TMR0 as a counter though, it wont work, it just doesn`t increment the variable.

And IF I start populating the flowchart with functions, for example, USB serial and eeprom functions, only Timer2 gets available?!
It does not matter if I again test the timers in the start of the flowchart, only Timer2 is working as it should.
Any suggestions in this matter?
Or could Matrix maybe recommend a similar chip that has been seriously tested in some project?

Best regards
Nick

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Timer problems PIC18LF14K50

Post by Steve-Matrix »

Perhaps the components you are adding are taking control of some of the other timers? Could you please post a project which works as expected and another that doesn't (and say which timers have stopped working) and we will investigate.

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: Timer problems PIC18LF14K50

Post by electronick »

Hi Steve.

Thanks for the quick reply.
Here is an example were timer0 is set up as a timer and working perfectly.
If I instead set it as counter(signal from RC5) nothing happens.

I will try to replicate the other timer issues later on, when this counter issue is solved.

Best regards.
Nick
Attachments
18LF14K50_test.fcfx
(11.85 KiB) Downloaded 12 times

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Timer problems PIC18LF14K50

Post by Steve-Matrix »

I don't have that chip to test, but I can suggest a few things to try.

The T0CKI needs to be an input and you can force it to be one by reading a value from pin C5 using an Input icon. It is also shared with the capture/compare/pwm module, so you can ensure that is disabled by setting CCP1CON=0; in a C code icon. Although both of these should be set as default.

Another thing to check is to ensure your input signal conforms to the electrical characteristics listed in the datasheet.

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: Timer problems PIC18LF14K50

Post by electronick »

Hi Steve.

Hardware is working when I set RC5 as an input, as for the other suggestions, no luck unfortunately.

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: Timer problems PIC18LF14K50

Post by chipfryer27 »

Hi

Maybe a stupid question, but ultimately what is it you wish to achieve from the input? If there is an issue with the Timer0 Counter, could you perhaps use IOC instead, albeit with a change of pins?

Regards

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: Timer problems PIC18LF14K50

Post by electronick »

Hi chipfryer27.

There are no such thing as a bad question I believe :-)
Unfortunately I need to use the prescaler in Timer0, as the freq of the input signal otherwise most likely will overflow the MCU or at least make all other operations stall.
As for using a different pin, it would mean ripping up hw design at a cost..
But I will give it a go today, coding it in C instead just to see if the problem reamains. A bit sad though, kind of takes away FCs purpose.

Best Regards
Nick

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: Timer problems PIC18LF14K50

Post by chipfryer27 »

Hi

If you have extremely fast pulses then you are probably right to use the counter. If you can use "C" to configure, then it probably means something in the interrupt isn't correct and I'm sure the team will investigate further.

I don't have that chip to try it myself, but I'll try the interrupt on another chip when I get the chance to see if it is unique to your chip or not. Probably won't be until the weekend though.

Regards

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: Timer problems PIC18LF14K50

Post by electronick »

Hi again.

Thank you so very much for getting involved :-)
I´ll try to get this tried during today, but probably in the weekend cause time´s a bit short today.

Regards
Nick

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Timer problems PIC18LF14K50

Post by Steve-Matrix »

chipfryer27 wrote:
Fri Feb 09, 2024 7:56 am
If you can use "C" to configure, then it probably means something in the interrupt isn't correct and I'm sure the team will investigate further.
Definitely! I've looked at the C being produced and it seems ok as far as I can tell, but without the chip I cannot test for sure. So if you do get this working via C then send me the project and I will incorporate into Flowcode.

Post Reply