Page 1 of 2

RC5 receive functionality

Posted: Sun Feb 20, 2022 9:08 am
by jan.didden
Hello,

I purchased the commsb pack for the RC5 component. There is also a short demo programme for the RC5 component, but that does give me some error messages I don't understand, see below. What am I doing wrong?

Code: Select all

Build date: Jul 30 2019
Part Support Version: 2.10
Copyright (C) 2019 Microchip Technology Inc.
RC5_Test_Rx.c: myisr()
  1462:	FCD_01bf2_RC5__Signal_Edge();
	^ (361) function declared implicit int (warning)
  1482:	FCD_01bf2_RC5__Timer_Event();
	^ (361) function declared implicit int (warning)
using updated 32-bit floating-point libraries; improved accuracy might increase code size
C:\ProgramData\MatrixTSL\FlowcodeV9\CAL\PIC\PIC_CAL_IO.c: 216: non-reentrant function "_FC_CAL_Port_In_DDR__x" appears in multiple call graphs and has been duplicated by the compiler
RC5_Test_Rx.c: 764: non-reentrant function "_FCD_01bf1_RC51__Initialise_States" appears in multiple call graphs and has been duplicated by the compiler
0: (500) undefined symbols:
	_FCD_01bf2_RC5__Signal_Edge(RC5_Test_Rx.obj) _FCD_01bf2_RC5__Timer_Event(RC5_Test_Rx.obj) 
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\ProgramData\MatrixTSL\FlowcodeV9\FCD\PIC\batch\pic_xc8_comp.bat reported error code 0x1

Re: RC5 receive functionality

Posted: Sun Feb 20, 2022 10:53 am
by jan.didden
Reading up a bit on RC5, there appears several coding methods exist, like the original Philips RC5 (bi-phase coding) or the NEC method, PWM coding. Does the Flowcode component handle only the original (Philips) RC5 bi-phase coding or does it also handle the PWM coding scheme as used by NEC? (My intended use is for NEC coding).

Also, what is the difference between RC5 and RC51 in the properties settings?

Jan Didden

Re: RC5 receive functionality

Posted: Sun Feb 20, 2022 1:29 pm
by medelec35
Hi Jan.
The issue with your flowchart is you added an additional RC5 component.
The RC51 is the RC5 component, but the last number is incremented every time you add a duplicate component.
If you added the third RC5 it will be RC53 etc.
As far as I'm aware The RC5 will only work with the RC5 protocol.
I have removed the additional RC5 and resized the original for you.
If you are importing from a flowchart where components were 2D/3D but are now the new 2D only style, then they will be tiny.
You will need to resize them.
If there are too many to resize then we can help.

Re: RC5 receive functionality

Posted: Sun Feb 20, 2022 3:49 pm
by jan.didden
Martin, thank you, that works! Funny enough, I deleted all RC5 related components and started with a clean flowchart, but couldn't get rid if the issues.
Your example compiles clean.
I think I'm all set now!

Jan Didden

Re: RC5 receive functionality

Posted: Sun Feb 20, 2022 4:24 pm
by medelec35
That's brillant.
Thanks for letting us know.

Re: RC5 receive functionality

Posted: Tue May 03, 2022 11:49 am
by jan.didden
Hmm. It seems an interrupt service routine can only be called from either a falling edge or a rising edge on a pin.
For this setup, I need to service both a falling and a rising interrupt.
The h/w of the PIC16F15355 can be set to interrupt on both a rising and a falling edge on a particular pin.
Is there a workaround that anybody knows of?
Maybe I could define two input pins as sources of an int, one on a rising edge, one on a falling edge, both calling the same service routine, but that seems a bit convoluted.

Jan

Re: RC5 receive functionality

Posted: Tue May 03, 2022 12:49 pm
by jan.didden
And for a lighter note:

prog.PNG
prog.PNG (135.06 KiB) Viewed 2625 times

Re: RC5 receive functionality

Posted: Wed May 04, 2022 11:19 am
by BenR
Hello,

Enabling the interrupt twice won't work as it will just set the edge to the last enabled edge. However you can take charge of the edge control bit yourself.

First enable the interrupt for the first edge you want to catch, e.g. rising.

Inside the interrupt macro increment a counter and then create a decision based on (counter & 1). This will be true on every odd count and false on every even count.

Yes branch C code icon - Interrupt on falling edge

Code: Select all

OPTION_REGbits.INTEDG = 0;
No Branch C code icon - Interrupt on rising edge

Code: Select all

OPTION_REGbits.INTEDG = 1;
Then as long as the edges aren't happening too fast you should interrupt on all edges.

Re: RC5 receive functionality

Posted: Thu May 05, 2022 10:14 am
by jan.didden
Thanks Ben, that's a good tip.
At this moment I'm only looking at a rising edge, because I think that looking at rising edges only gives me an umambiguous pulse length.
Those NEC message designers were pretty smart!

Jan

Re: RC5 receive functionality

Posted: Thu May 05, 2022 1:47 pm
by jan.didden
Next hurdle. For some reason, the timer returns zero elapsed time, even with a deliberately inserted 4ms delay.
Looking at the timer properties there is a 2MHz coount rate specified with no option to change it.
Does FC, knowing the osc freq, insert a prescaler to get to 2MHz?
My processor runs at 32MHz.
Could that give a conflict?

Edit: a 2MHz instruction rate implies an 8MHz clock, right.

Jan Didden