PIC 16F1784

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

Moderator: Benj

Post Reply
jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

PIC 16F1784

Post by jj34 »

Hello
I am about to start a new projet using PIC 16F1784.
Can you provide an FCDx for this PIC ?
Thanks.

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: PIC 16F1784

Post by QMESAR »

The problem with this family of micro controller too me looks like the BoostC compiler does not support them and then I suppose it is hard for Matrix to support them as well

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

OK, but the 16F1784 is exactly a 16F1783 with more I/Os and 40 pins and the 16F1783 is in the boostC supported device list.
I really need the additional I/Os and more I already have a 16F1784 .... !

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: PIC 16F1784

Post by kersing »

Until Matrix embeds another compiler there are a number of options:
  • Ask the authors of BoostC to add the device
  • Add the device to BoostC yourself
  • Get someone else to add the device to BoostC
Once the device has been added it can be supported by Flowcode.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

I am not a programming expert, reason why I baught Flowcode to start ....
But taking my part in that implementation is fair enough.
I probably can use the PIC16F1783.bas and PIC16F1783.h files that are in my boostc folder to expand them to a PIC16F1784.
Eventually it is only a task of adding the missing #defines from the PIC Data Sheet, I am not so sure about the last part ( the dim definitions )
With a little help I may be able to also create a PIC16F1784.fcdx file even if I do not know the fcd langage.

But do you mean that this will be enough for Matrix people to implement their part in Flowcode ?

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: PIC 16F1784

Post by QMESAR »

jj34 wrote:I probably can use the PIC16F1783.bas and PIC16F1783.h files that are in my boostc folder to expand them to a PIC16F1784.
Eventually it is only a task of adding the missing #defines from the PIC Data Sheet, I am not so sure about the last part ( the dim definitions )
With a little help I may be able to also create a PIC16F1784.fcdx file even if I do not know the fcd langage.

But do you mean that this will be enough for Matrix people to implement their part in Flowcode ?
In my opinion Ben and the guys will give you an clear answer to this ,I based my comment on this tread http://www.matrixtsl.com/mmforums/viewt ... 56&t=15569 I asked for support for 16F17xx family and I got an clear answer,Clearly a person can try to add it yourself how successfully depends on the persons programming ability and his knowledge about Software and computers in general ,I think this is above most people using Flowcode ,avoiding such things is the essential part of Flowcode to me and the reason why people buy FC



Hope that somehow MATRIX will add this family :D

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: PIC 16F1784

Post by Benj »

Hello,

If BoostC support the chip officially then yes we can create an FCD file no problem. The main reason we don't want to add the BoostC files ourselves is that:

a) we might miss something key which would be hard to find and debug
b) we are doing BoostC's work for them, we have our own work to do
c) We move away from the actual BoostC release meaning if they find a big problem or fix a bug then merging their latest compiler with our files gets more prone to error

We have a plan to move away from BoostC for this reason as well as others but it is currently looking like this will be a v7 feature.

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Hi Benj
I understand your point of course, but the 16F1784 is really just a bigger 16F1783, more pins, more I/Os but additional PortD and E are not IOC capable, one more PSMC (3 vs 2 ) and that's it, and as written before the 16F1783 is supported by Boostc.

It's a bit my fault knowing that the 16F178x family was supported I did not care to check that the 1784 and up were not.
I only decided to use this one because of it's sophisticated individual and flexible ioc capabilities, the number of gpio's and the two timers (T0 and T1) simultaneously capable to act as counters which I need.
I have already finished all the electronic design as well as the physical circuit layout and mind you I would'nt like to start all over again.

Thus I will now do the boostc .bas and .h description files and send them to you, and really appreciate that you 'll do the FCD as this is beyond my knowledge, or at least it'd take far too long.

I am only an oldish amateur doing those projects for my own pleasure .....
Thanks anyway.

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

OK, I have now created 3 new BoostC files : PIC16F1784.TDF - PIC16F1784.bas and PIC16F1784.h ( attached )
and also modified map.txt - BoostCPic16.h and boostbasicpic16.bas to include the PIC16F1784 def files.

I hope I have not missed too much and made too many typos ..... ( I did cross check, but ..... :oops: )

Still I changed a few bit names as they were different from the data sheet, that is the ODCONx bits and SLRCONx bits that were respectively ODCONxn : now ODxn and SLRCONxn now SLRxn.
I did it in all three above new files.

Anything else I can do ?

PS: only one attachment at a time or how to add more ?
Attachments
PIC16F1784.h
(97.61 KiB) Downloaded 247 times

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Let's try it this way ...
Attachments
PIC16F1784.rar
(23.4 KiB) Downloaded 237 times

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Hi Benj or anybody else from Matrix support ....
Any chance to at least get a reply ?

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: PIC 16F1784

Post by Benj »

Hello,

Right I'm on with the FCD now. Shouldn't take long. Noticed there may be an additional change required in the map.txt file but will know more shortly.

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: PIC 16F1784

Post by Benj »

Hello,

Right here is the FCD file, I am getting some compilation errors though.

Code: Select all

Flowcode1.c(72:1): error: unknown identifier 'ansela'
Flowcode1.c(72:1): error: invalid operand 'ansela'
Flowcode1.c(72:8): error: failed to generate expression
Flowcode1.c(73:1): error: unknown identifier 'anselb'
Flowcode1.c(73:1): error: invalid operand 'anselb'
Flowcode1.c(73:8): error: failed to generate expression
Flowcode1.c(74:1): error: unknown identifier 'anseld'
Flowcode1.c(74:1): error: invalid operand 'anseld'
Flowcode1.c(74:8): error: failed to generate expression
Flowcode1.c(75:1): error: unknown identifier 'ansele'
Flowcode1.c(75:1): error: invalid operand 'ansele'
Flowcode1.c(75:8): error: failed to generate expression
Flowcode1.c(77:1): error: unknown identifier 'option_reg'
Flowcode1.c(77:1): error: invalid operand 'option_reg'
Flowcode1.c(77:12): error: failed to generate expression
16F1784.fcdx
(19.49 KiB) Downloaded 150 times
Aha this could be why...
and also modified map.txt - BoostCPic16.h and boostbasicpic16.bas to include the PIC16F1784 def files.

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Thanks a lot Ben,
yes I also mod the 3 other files but did not send them .....
Here they are attached.
Attachments
Boostc_16F1784_other.rar
(5.7 KiB) Downloaded 146 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: PIC 16F1784

Post by Benj »

Hello,

Thanks for the files they seemed to help. I'm now getting these errors.
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2251:21): error: unknown identifier 'PIR3'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2251:20): error: failed to set fixed address for variable 'pir3'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2298:25): error: unknown identifier 'DAC2CON1'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2298:24): error: failed to set fixed address for variable 'dac1con1'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2354:24): error: unknown identifier 'SSP1CON'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2354:23): error: failed to set fixed address for variable 'ssp1con'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2382:24): error: unknown identifier 'CCP3CON'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2382:23): error: failed to set fixed address for variable 'ccp3con'
If you get this working then please send me the latest compiler files and I will add them to our local image so they will be packaged in the next release.

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Well that's not too bad for a very first run, probably some "missed" ....
I'll check this now.

But as said before I still have a few hardware problems to fix before being able to start programming "seriously".
My fear was can I commit that PIC in my project or not, that would have implied a thorough hardware redesign otherwise.

My project is a two tubes video screen, and what holds me now is a seemingly very simple component : I need two rotary reflectiv targets to stick at the end of the tubes to determine their amount of rotation and read by two HOA2498 and as simple as it may be, the actual making of them is very difficult to get a clean reliable sensing.
it's driving me nuts just now .....

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Hello,
I have been thru the detected errors as follows :
==> Data Sheet error : PIR3 register's definition is missing (unimplemented) but its only bit def is defined, so ........ added the definition
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2251:21): error: unknown identifier 'PIR3'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2251:20): error: failed to set fixed address for variable 'pir3'
The remainder were mine : typo errors, corrected accordingly
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2298:25): error: unknown identifier 'DAC2CON1'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2298:24): error: failed to set fixed address for variable 'dac1con1'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2354:24): error: unknown identifier 'SSP1CON'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2354:23): error: failed to set fixed address for variable 'ssp1con'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2382:24): error: unknown identifier 'CCP3CON'
C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include\PIC16F1784.h(2382:23): error: failed to set fixed address for variable 'ccp3con'
I also browsed thru your FCDx file, and again I must say that my fcd language is very limited, still apart the interrupt handlers, the rest is fairly easy to understand.

I have a few comments :
- The PIC16F1784 program size is 4096 KB ( not 8192 )
- In Config word2, should VCAPEN be = 21 ? (instead of 20 )
- Cosmetics : Pins RA4 and RE2 names there's no CCP5
- TMR2 interrupt handler : Prescaler 1:64 is missing

But my main concern is about the IOC capabilities of this chip.
Your FCD seems to handle the ioc interrupts only globally and of PortB only, where the 16F1784 has ioc for PortA, B, C and RE3 ( the latter being less important).

One of the strongest point of this PIC16F178x family is the wider range and flexibility of the ioc concept with ALL pins being individual controlable with choice of trigger edge and interrupt flags making the programming that much easier.
By the way this was the second main point that made me choose that PIC ( the number of I/Os being the first).

Do you think that you can implement the full range of this chip's ioc capabilities in the FCD ?

Attached the set of corrected BoostC files.
Attachments
PIC16F1784.rar
(29.06 KiB) Downloaded 133 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: PIC 16F1784

Post by Benj »

Hello,

Many thanks for posting the compiler fixes and your comments.
I also browsed thru your FCDx file, and again I must say that my fcd language is very limited, still apart the interrupt handlers, the rest is fairly easy to understand.
The FCDX files are not too bad, they are just basic XML at the end of the day but the syntax has to be correct for Flowcode to know what's going on.
- The PIC16F1784 program size is 4096 KB ( not 8192 )
The datasheet seem unsure about this and the product page says 7KB. The prog mem size given at the start of the datasheet is in words not bytes. This value is cosmetic anyway and is not going to cause issues if incorrect.
- In Config word2, should VCAPEN be = 21 ? (instead of 20 )
Yes well spotted, this has now been fixed.
- Cosmetics : Pins RA4 and RE2 names there's no CCP5
Yes good spot, these are now gone.
- TMR2 interrupt handler : Prescaler 1:64 is missing
1:64 prescaler is now present.
But my main concern is about the IOC capabilities of this chip.
Your FCD seems to handle the ioc interrupts only globally and of PortB only, where the 16F1784 has ioc for PortA, B, C and RE3 ( the latter being less important).
The IOC should now be fully functional across all supported ports. Please note that there is only one interrupt for all IOC pins. You would likely have to keep track of which pin has fired the interrupt inside your flowchart by comparing the pin states from the last interrupt with the current states. Or using C code to view and reset the various IOC pin flags.

Let me know if you come across anything else.
Attachments
16F1784.fcdx
(19.97 KiB) Downloaded 123 times

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Benj, again thanks a lot.
Yes indeed it's the same interrupt but with all the individual bit's interrupt flags being set accordingly, it should be that much easier to know which did what, especially with 3 full ports at hand.
But as a matter of learning something, could you explain how this works in the ioc interrupt handler :

<ioc config='0x0F' >
<rising port='0' mask='0xFF' />
<falling port='0' mask='0xFF' />
<rising port='1' mask='0xFF' />
<falling port='1' mask='0xFF' />
<rising port='2' mask='0xFF' />
<falling port='2' mask='0xFF' />
<rising port='4' mask='0x08' />
<falling port='4' mask='0x08' />
</ioc>

By the way, when I have finished my project (may take some time though ...), and as there's very little difference in the 16F178x family, if it is of interest I can then extend the boostc files to cover the whole family.

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: PIC 16F1784

Post by Benj »

Hello,

I don't have access to all the details currently but it's something like this...

16F877A - Only supports both edges "4" and is limited to portb "1" and the upper 4 pins "0xF0"
<ioc config='4' >
<rising port='1' mask='0xF0' />
<falling port='1' mask='0xF0' />
</ioc>

16F1784 - Supports both edges 0x4, rising edge 0x2, falling edge 0x1, pin masking 0x8 = "0x0F" and is limited to ports a,b,c,e "0,1,2,4" and the masked pins
<ioc config='0x0F' >
<rising port='0' mask='0xFF' />
<falling port='0' mask='0xFF' />
<rising port='1' mask='0xFF' />
<falling port='1' mask='0xFF' />
<rising port='2' mask='0xFF' />
<falling port='2' mask='0xFF' />
<rising port='4' mask='0x08' />
<falling port='4' mask='0x08' />
</ioc>
if it is of interest I can then extend the boostc files to cover the whole family.
That would be very generous and fantastic if you wouldn't mind doing this, I have already put your current compiler mods into the build so they will be there for the next update.

jj34
Posts: 15
Joined: Mon Sep 08, 2014 10:57 am
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: PIC 16F1784

Post by jj34 »

Hi Benj,
The PIC16(L)F178x family is now complete, attached is a full reload of the new Boostc files.
I also corrected another few glitches in the 1784 files and I hope I haven't introduced any new ones.
Now its up to you to create the corresponding FCDx's :D

But concerning the ioc handling, I think something is not quite right.
In the PIC16F1784 FCDx ioc interrupt handler, to exit the handler you clear bit IOCIF, this bit is an electronic "AND" of the 25 individual gpio IOCnFx flags, but IOCIF is Read Only and automatically cleared once ALL the IOCnFx flags are cleared by software. This obviously has to be done on a single flag basis at the end of that flag's interrupt handling, to not loose any other ioc interrupt that may have occured in the mean time.
Yes it gets a bit complicated .... The easiest is probably to appropriately clear those flags in the program in C boxes, but then what about simulation ?
Any idea how to handle this ?
Attachments
PIC16(L)F178x.rar
(245.52 KiB) Downloaded 156 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: PIC 16F1784

Post by Benj »

Hello,

Thanks for the compiler files, I have added these to the code base.

I have fiddled with the IOC type interrupt and hopefully it should now work correctly without needing any C code.
16F1784.fcdx
(19.97 KiB) Downloaded 154 times
If this is ok then I will generate the other FCDs in the family based on this one.

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: PIC 16F1784

Post by Benj »

Hello,

Here are all the Flowcode definition files for the chips.
PIC16F178x.zip
(34.9 KiB) Downloaded 180 times
Let me know if you spot any problems.

Post Reply