Page 1 of 1

Problem Compiling a Flowcode Project using SPI Slave module

Posted: Wed Apr 24, 2019 11:48 am
by Bernie_P
Hi,

I have been trying to compile a simple SPI Slave Flowcode program based on an example in this thread viewtopic.php?t=20526 the only difference is that the target device I am using is a PIC16F1933, SPI 'Channel 1' instead of 'Channel 2' and I am using the corresponding SPI IO's for the device.
Unfortunately, every time I try to compile the code to a HEX file, I get the error message below.

Does the Flowcode SPI Slave module only work with a limited number of PIC microcontrollers and is the PIC16F1933, not one of them, or have I just made a mistake in my Flowcode program.
Target folder: \\xxxx.local\data\REDIRE~1\PDD Users\Documents\PIC\SPI Slave
Source name: \\xxxx.local\data\Redirected Folders\PDD Users\Documents\PIC\SPI Slave\SPI_Slave_Prototype1.fcfx
Title:
Description:
Device: PIC.16F.16F1933
Generated by: Flowcode v8.1.1.11
Date: Wednesday, April 24, 2019 09:53:07
Users: 1
Registered to:
License key: *****
https://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat 16F1933 "\\xxxx.local\data\REDIRE~1\PDD Users\Documents\PIC\SPI Slave\" "SPI_Slave_Prototype1"
'\\xxxx.local\data\REDIRE~1\PDD Users\Documents\PIC\SPI Slave'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

X:\REDIRE~1\PDD Users\Documents\PIC\SPI Slave>C:\PROGRA~2\Flowcode\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=16F1933 "SPI_Slave_Prototype1.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32
Microchip MPLAB XC8 C Compiler (Free Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

using updated 32-bit floating-point libraries; improved accuracy might increase code size
. . .

0: (500) undefined symbols:
_FC_CAL_SPI_Slave_Init_1(SPI_Slave_Prototype1.obj) _FC_CAL_SPI_Slave_RxByte_1(SPI_Slave_Prototype1.obj) _FC_CAL_SPI_Slave_TxByte_1(SPI_Slave_Prototype1.obj)
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1



FINISHED
SPI_Slave_Prototype1.fcfx
(9.51 KiB) Downloaded 220 times
Thanks.

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Wed Apr 24, 2019 4:56 pm
by Benj
Hello,

I have looked into this for you now and hope I have fixed the issue. The latest files on the update system should hopefully solve the problem for you.

Let me know how you get on.

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Fri Apr 26, 2019 8:43 am
by Bernie_P
Hi Ben,

Thank you for looking into the issue, I have applied the update and the code now compiles without erroring.

Thanks

Bernie.

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Thu Jan 23, 2020 3:40 pm
by Claudyy
Hi, I'm new here ang badly need help.

I'm connecting 2 PIC via SPI. I'm using Pic18f4620 as MASTER and Pic18f26k22 as slave. I'm using Flowcode V5. I don't know how to set the pic18f26k22 in spi slave mode in flowcode 5.
Ps, I'm kinda new so I don't know much about C code.

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Thu Jan 23, 2020 4:52 pm
by Benj
Hello,

Do you want to post the slave code you have so far and we will have a look and try to advise. In v5 you can access the registers by using lower case names in a c-code icon.

for example

Code: Select all

ssp1con = 0b01010101;

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Fri Jan 24, 2020 4:37 am
by Claudyy
Hello Benj, this is kinda embarrassing.

Before I was using PIC as a SPI master and a p10 led matrix as a slave and I don't have any problem. It works perfect.
But now I'm trying a Pic as a Slave, and I thought it just the same thing, I just gonna select the "GetChar" function in the SPI component macro in flowcode 5 , and I Connect SCK-SCK, SDO-SDA.
Well obviously it didn't work. And I learned that the both PIC is operating in master mode, and generating their own clocks, (I'm not sure), and I feel really stupid.

I looked at the datasheet, I have to set the SPI as a slave in C code, but i never used the C block before.

Here's my Flowchart,
I'm just trying to control a LED, If the slave receive a certain character.
SPI SLAVE.png
(12.79 KiB) Downloaded 415 times

Re: Problem Compiling a Flowcode Project using SPI Slave module

Posted: Fri Jan 24, 2020 11:06 am
by Benj
Hello,

Here are the steps you need to do to establish the slave functionality.

1) Initialise the SPI module in slave mode. Look at the various SPI registers and assign values to enable module in slave mode.
2) Enable an SPI interrupt to allow you to see when an SPI slave event has occurred. Look at custom interrupts in the v5 help for information on this.
3) Inside the interrupt macro read the SPI buffer to collect the incoming data and write to the SPI buffer to set the next outgoing data value.

Here is a C program I made a while back.
https://github.com/RowlandTechnology/MU ... Firmware.c

The various code exists at the indicated lines.

1) Line 363
2) Line 381
3) Line 702

Hope this helps.