Page 1 of 1

Flowcode v5.4 PIC18F47J53 Code Error

Posted: Sat Aug 25, 2012 10:35 pm
by Mark
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

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Sat Aug 25, 2012 11:16 pm
by Enamul
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.

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Sun Aug 26, 2012 9:02 pm
by Mark
Hi Enamul,

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

Best Regards,

Mark

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Tue Sep 11, 2012 9:50 pm
by Mark
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

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Wed Sep 12, 2012 12:23 am
by Enamul
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.

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Wed Sep 12, 2012 9:40 am
by Benj
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
(20.76 KiB) Downloaded 391 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.

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Wed Sep 12, 2012 10:27 pm
by Mark
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

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Thu Sep 13, 2012 10:16 am
by Benj
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.15 KiB) Downloaded 397 times
PIC_CAL_I2C.c
(20.99 KiB) Downloaded 405 times
Let me know how you get on.

Re: Flowcode v5.4 PIC18F47J53 Code Error

Posted: Sun Sep 16, 2012 9:10 pm
by Mark
Ben,

Thanks, works fine.

Mark