Flowcode v5.4 PIC18F47J53 Code Error

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Flowcode v5.4 PIC18F47J53 Code Error

Postby Mark » Sat Aug 25, 2012 10:35 pm

Flowcode v5.4 PIC18F47J53 Code Error "SOS" :-o (rather than "OS" :-) )

The code both for the FCD file and the Interrupt set-up code file appear to have an error:

//Clock
//Interrupt: Enable TMR1
st_bit(intcon, PEIE);
st_bit(t1con, TMR1ON);
cr_bit(t1con, TMR1CS0);
st_bit(t1con, TMR1CS1);
cr_bit(t1con, T1SOSCEN);
t1con = (t1con & 0x0F) | 0x30;
st_bit(t1con, RD16);
st_bit(intcon, GIE);
st_bit(pie1, TMR1IE);

[TMR1]
Name="TMR1"
HandlerCode="#ifndef MX_INTHANDLER_pir1_TMR1IF\n#define MX_INTHANDLER_pir1_TMR1IF\nif (ts_bit(pir1, TMR1IF) && ts_bit(pie1, TMR1IE))\n{\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 1;\n\t#endif\n\tFCM_%n();\n\tcr_bit(pir1, TMR1IF);\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 0;\n\t#endif\t\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n"
EnableCode="st_bit(pie1, TMR1IE);\n"
DisableCode="cr_bit(pie1, TMR1IE);\n"
OptCnt=3
PrescaleOpt=2
MaxTimerOverflow=65536
Opt1="Clock Source Select"
Opt1Cnt=3
Opt1_1="Internal clock (Fosc)"
Opt1_1Val="st_bit(intcon, PEIE);\nst_bit(t1con, TMR1ON);\nst_bit(t1con, TMR1CS0);\ncr_bit(t1con, TMR1CS1);\n"
Opt1_2="Internal clock (Fosc/4)"
Opt1_2Val="st_bit(intcon, PEIE);\nst_bit(t1con, TMR1ON);\ncr_bit(t1con, TMR1CS0);\ncr_bit(t1con, TMR1CS1);\n"
Opt1_3="T1CKI Pin"
Opt1_3Val="st_bit(intcon, PEIE);\nst_bit(t1con, TMR1ON);\ncr_bit(t1con, TMR1CS0);\nst_bit(t1con, TMR1CS1);\ncr_bit(t1con, T1SOSCEN);\n"


"T1SOSCEN" is present which shold be "T1OSCEN". This gives rise to the error:


..................
Interrupt Usart Test.c(433:22): error: unknown identifier 'T1SOSCEN'
Interrupt Usart Test.c(433:22): error: invalid operand 'T1SOSCEN'
Interrupt Usart Test.c(433:17): error: failed to generate expression
Interrupt Usart Test.c(433:13): error: invalid operand '~(1 << ( T1SOSCEN))'
Interrupt Usart Test.c(433:10): error: failed to generate expression
Interrupt Usart Test.c success

failure
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED

Simply changing "T1SOSCEN" to "T1OSCEN" in both instances solves the problem.

Changing the FCD file is strightforward with a text editor. Not sure how to change the interrupt setup routine other than with the custom code option??
Other knock on effects in the code??

Hope this helps someone.

Mark
These users thanked the author Mark for the post:
Enamul (Sat Aug 25, 2012 11:16 pm)
Rating: 5.26%
 
Go with the Flow.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Enamul » Sat Aug 25, 2012 11:16 pm

Hi,
Thanks for the post about TMR1, TMR3 & TMR5 FCD problem. I have manged to replicate the issue if I select external clock source as clock. I have attached here the corrected FCD.
Attachments
18F47J53.fcd
(28.24 KiB) Downloaded 160 times
These users thanked the author Enamul for the post:
Mark (Sun Aug 26, 2012 9:02 pm)
Rating: 5.26%
 
Enamul
University of Nottingham
enamul4mm@gmail.com

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Mark » Sun Aug 26, 2012 9:02 pm

Hi Enamul,

Many thanks for the follow-up, yes I can see the other faults, and their correction.

Best Regards,

Mark
Go with the Flow.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Mark » Tue Sep 11, 2012 9:50 pm

It looks like there is another code error, now with the I2C Port 2.

The register name SSP2CON is attempted to be used but the ports are
actually SSP2CON1 and SSP2CON2 as present in the chip definition file.

As the CCode uses the BoostC library function I'm not sure how to amend the code.

The error text when compiling to C is :

File name: C:\Users\User\Documents\Flowcode\Tiertex PIC18F47J53\I2C Test.c
Title:
Description:
Generated by: Flowcode v5.4.0.0
Date: Tuesday, September 11, 2012 21:37:10
Licence: Professional
Registered to: Blanked
Licence key: Blanked
http://www.matrixmultimedia.com
Launching the compiler...
D:\Electronics\Flowcodev5\Tools\boostc\boostc_pic18_flowcode.exe -v -t PIC18F47J53 "I2C Test.c"
BoostC Optimizing C Compiler Version 7.04 (for PIC18 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2011 Pavel Baranov
Copyright(C) 2004-2011 David Hobday

Licensed to FlowCode User under Single user Pro License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited


I2C Test.c
Starting preprocessor: D:\ELECTR~1\FLOWCO~1\Tools\boostc\pp.exe "I2C Test.c" -i D:\ELECTR~1\FLOWCO~1\Tools\boostc\include -d _PIC18F47J53 -la -c2 -o "I2C Test.pp" -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX


.................

D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(344): error: left operand must be l-value
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(344:13): error: failed to generate expression
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(345): error: left operand must be l-value
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(345:13): error: failed to generate expression
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(360:2): error: unknown identifier 'ssp2con'
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(360:2): error: invalid operand 'ssp2con'
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(360:10): error: failed to generate expression
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(382:4): error: unknown identifier 'ssp2con'
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(382:4): error: invalid operand 'ssp2con'
D:\Electronics\Flowcodev5\CAL\PIC\PIC_CAL_I2C.c(382:13): error: failed to generate expression
I2C Test.c success

failure

.Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.


FINISHED

The chart that produces this is attached.

The error does not occur with I2C port option 1, Any suggestions?

Thanks

Mark
Attachments
I2C Test.fcf
File that generates the issue
(13.5 KiB) Downloaded 106 times
Go with the Flow.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Enamul » Wed Sep 12, 2012 12:23 am

Hi Mark,
Yes. You have spotted another issue in I2C 2 which is not present in I2C 1. I will have a look and seems BEN need to put a hand to solve this issue.
Enamul
University of Nottingham
enamul4mm@gmail.com

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

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Benj » Wed Sep 12, 2012 9:40 am

Hello,

Right I think I have fixed the issue by doing the following.

1) Replace the I2C CAL file with this one. "Flowcode/v5/CAL/PIC/"

PIC_CAL_I2C.c
(21.34 KiB) Downloaded 133 times


2) Add the following code to the defines section of the supplementary code window (available via the project options window).

Code: Select all

#define ssp2con ssp2con1


The I2C peripheral 2 is remappable on your device. I think it should be being remapped to pins B1 (SDA) and B2 (SCL). If this is not the case on your hardware or you want to remap to other pins then let me know.

Let me know how you get on.
These users thanked the author Benj for the post:
Enamul (Wed Sep 12, 2012 9:56 am)
Rating: 5.26%
 

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Mark » Wed Sep 12, 2012 10:27 pm

Ben,

Thanks for the prompt reply.
The compile error is no longer present.

However, I am not seeng any outputs (scope on all pins and particularly D0 and D1, see data sheet page as attached).

With I2C 1 port choice I am seeing activity on RB4 and RB5, although whilst I2C Start is clearly OK MI2C Send Byte Transaction seems 3 bytes short.

Any suggestions.

Thanks again.

Regards,

Mark
Attachments
18F47J53 Data SheetPage.pdf
(53.23 KiB) Downloaded 163 times
Go with the Flow.

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

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Benj » Thu Sep 13, 2012 10:16 am

Hello Mark,

Right I think I have now fixed some of the bugs and hopefully I2C channel 2 should work correctly for you now using the updated files attached below. The I2C is not remappable, not sure why I thought it was, and the 18F2xJ53 devices seem to only have one I2C channel even though the Microchip product selector says it has two.

18F47J53.fcd
(27.94 KiB) Downloaded 117 times

PIC_CAL_I2C.c
(21.59 KiB) Downloaded 137 times


Let me know how you get on.
These users thanked the author Benj for the post:
Mark (Sun Sep 16, 2012 9:09 pm)
Rating: 5.26%
 

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Flowcode v5.4 PIC18F47J53 Code Error

Postby Mark » Sun Sep 16, 2012 9:10 pm

Ben,

Thanks, works fine.

Mark
Go with the Flow.