PIC24FV32KA304 and INT0 --> BUG !!!!!

A forums to allow bugs and problems with Flowcode v6 to be reported and resolved.

Moderator: Benj

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Sun Oct 16, 2016 10:08 am

Hello Benj,
now I have a other problem with the extern interrupt 0. After several hours I found out why. Here happens the same problem like counting extern clock signals into timer 4, I posted before.
In the attached program a led will be toggled in the main loop. Clocking extern int0 toggles a second led. Sometimes the int0 led stays for 2 clocks or more on or off ?????
If you disable the output box "b14", int0 works like expected!
When your output box is writing to the port, do you write altough to trisb or setting analog to digital again? In the post before I could catch a glitch with the oscilloscope.

Writing directly to the portpin with a c-box solved the problem. I declare the portpins in a c-box at the beginning of the program and removed the output boxes.
Input box replaced --> FCV_HALL_SENSOR_BIT = PORTBbits.RB14;
Output box replaced --> PORTA |= (1 << 10);
This works !!!!!
What is flowcode doing. Do you collect all settings in the beginning of the program or when every in- and outputbox will be called? In my case I couldn`t use the boxes in the moment
with the cpu I use.


Best regards
Jorg
Attachments
INT0_Problem_PIC24FV32KA304_V6.fcfx
(6.42 KiB) Downloaded 199 times

User avatar
Benj
Matrix Staff
Posts: 14223
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4363 times
Been thanked: 4096 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Benj » Mon Oct 17, 2016 10:23 am

Hi Jorg,

The C code for the B14 -> test_bit1 looks like this.

Code: Select all

FCV_TEST_BIT1 = FCP_GET(B, B, 0x4000, 14);


This then translates to this code.

Code: Select all

#define FCP_GET(Type, Port, Mask, Shift) FCP_GET_##Type(_##Port, Mask, Shift)
#define FCP_GET_B(Port, Mask, Shift)   (FC_CAL_Port_In_DDR__x((&FCP_PORT##Port), (&FCP_TRIS##Port), (Mask), (Shift)))

MX_UINT16 FC_CAL_Port_In_DDR__x (volatile unsigned int* PORT, volatile unsigned int* DDR, MX_UINT16 InMask, MX_UINT8 Shift)
{
   *DDR |= InMask;
   return (*PORT & InMask) >> Shift;
}


I'm not sure why this would be conflicting with the INT unless it is simply the additional instructions required to keep the code dynamic.

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Mon Oct 17, 2016 12:06 pm

Hello Benj,
I´m not so deep inside C++ like you. But when I take all facts together I would like to explain it in that way:
The problem is not the int0. In my trials I noticed, that he wouldn`t start sometimes.
The problem of extern counting into tmr4 is not timer4.
If one of these extern signals comes in the same time, when a input or output box is called and where at specially point something happens
with the port and then there appears a second glitch to these modules. But why is it working with the C-lines I wrote?
May be that this happens only with the pic24-series?
When my code will be execute, there is no touch to trisb or so, is it right?


Best regards
Jorg

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Sun Nov 13, 2016 10:10 am

Hello Benj,
I visit the electronica in munich and discuss my problem with microchip face to face.
They said, that the ports today are very complex and can set up for varius functions. This setup has to be done at first in the program in main!!! If you change something later, while the program runs normally,
then the effects, I have, can occur.
So what happens inside flowcode? Are all setups (trisa, analog select and so on...) are standing at first in the program or will they be written again while using etc. a output-box?

In my case I wrote a setup of the cpu at the beginning in a c-box and replace inside my program all output- and inputboxes with the lines like:
Input box replaced --> FCV_HALL_SENSOR_BIT = PORTBbits.RB14;
Output box replaced --> PORTA |= (1 << 10);

THAT WORKS !!!

But this is not the idea of flowcode. What can you say to this situation?

Best regards
Jorg

User avatar
Benj
Matrix Staff
Posts: 14223
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4363 times
Been thanked: 4096 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Benj » Mon Nov 14, 2016 11:59 am

Hello Jorg,

The Flowcode input icon will put the tris register into input mode and then read the state of the port pin.

The output icon will put the tris register into output mode and then set the value of the latch register.

We are looking into intelligent ways to skip the tris state change for v7 to increase efficiency.

I've not come across a problem with I/O using Flowcode even using the new PIC devices. Is it possible to get a scope on the problematic pins and see if you can see exactly what is going wrong. Maybe it is a strict timings issue or maybe a glitch is working it's way in when altering the tris register?

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Mon Nov 14, 2016 2:14 pm

Hello Benj,
the same happens by counting with timer and toggle out a pin. Please have a look to the link below, I reported some days ago.
After clicking to the link scroll a little bit down and then you will see a screenshot from my oscilloscope.

viewtopic.php?f=54&t=18079

"Is it possible to get a scope on the problematic pins" --> It happens with the complete port !
This have to do while setting up the port is only possible for the whole port says Microchip. It`s not only one pin.

Best regards
Jörg

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Tue May 16, 2017 3:54 pm

Hello Matrix-Team,
I´ve now problems with the PIC16F1825. The c-port was used with differant functions. Here happens the same as with the PIC24FV32KA304. A high signal coming out on one port pin was sometimes only as a glich to see. Replace the output boxes with c-lines resolve this problem! Have you done anything in Flowcode against this problems?
What happens with version 7?


Best regards
Jörg

User avatar
Benj
Matrix Staff
Posts: 14223
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4363 times
Been thanked: 4096 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Benj » Tue May 16, 2017 5:58 pm

Hello Jörg,

Flowcode v7 now has a NoDDR option to allow you to access pins using a calculation icon without changing or resetting the DDR state.

NoDDR.jpg
NoDDR.jpg (42.4 KiB) Viewed 5242 times


We have started to roll this out into components that require very strict or high speed timings and it does make a difference.

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Mon May 29, 2017 8:32 pm

If I´m understand right, a calculation-box will be used with c-lines to managed this situation.
If yes, where is the philosophy of flowcode with the c-boxes?
If you set up a uart channel, you take the belonging component and choose "init".
Is it not a good way to do it with ports, too? In the beginning of the programm
a component box for ports will be placed and set up. Combining with other modules to have
a big setup-box for the complete cpu to setup at start of the program is a new idea for you.
Every program starts at first with control of the cpu-pins to control the electronic around.

What do think about a new box for setting up the oscillator section?

But just back to what you have implementated. To use this, I`ve to put a output-box in the beginning
of the program,to give a pin a direction. In the program I then use this new c-lines for setting and clearing that pin,
that`s right?


Best regards
Jörg

User avatar
LeighM
Matrix Staff
Posts: 1875
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 439 times
Been thanked: 633 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby LeighM » Tue May 30, 2017 8:42 am

But just back to what you have implementated. To use this, I`ve to put a output-box in the beginning
of the program,to give a pin a direction. In the program I then use this new c-lines for setting and clearing that pin,
that`s right?

Yes, but the NoDDR options are in the "Calculation" icon, not the "C" icon.

Jörg Güldner
Posts: 71
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 16 times
Been thanked: 5 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby Jörg Güldner » Wed May 31, 2017 1:54 pm

Hello LeighM,
what is about the idea in the first text-block from me on monday?
Did you discuss this in your development round?
Is it not a good way to setup all in the beginning of the program?
That makes the program shorter and quicker.


Best regards
Jörg

User avatar
LeighM
Matrix Staff
Posts: 1875
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 439 times
Been thanked: 633 times
Contact:

Re: PIC24FV32KA304 and INT0 --> BUG !!!!!

Postby LeighM » Wed May 31, 2017 3:08 pm

Yes, you have good ideas, thanks for contributing them.
We have considered a few ideas like these.
With the addition of the NoDDR option, the port pins can be set up at the start as you suggest, although not in a single box.
So it is achievable in Flowcode 7 without us introducing new concepts that might confuse existing users.
Historically, pin configurations have changed "on the go", such that ports and peripherals can be reconfigured as the program executes.
We add your comments to our list of ongoing possible additional features.
Thanks.