Problem with Flowcode SPI macro with accelerometer component

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

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Problem with Flowcode SPI macro with accelerometer component

Post by Mathy »

Hi !

I think i found a problem with your accelerometer component in SPI hardware mode.
It is impossible to collect data into variable.
Do I need to do something else to make it works ?

In software I2C, it works well :)

Thank you for your help.

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello,

I tested the hardware using SPI but that was a long time ago and our hardware all uses the I2C bus. I will have a dig and see if I can work out what's going wrong.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

I had also a problem with FAT16 component but I found on this forum the updated component file to replace.
Now I can write without problem on my SDHC !

But, if I use accelerometer and SDCARD in SPI mode, I have this error message during compilation :

C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(51): Illegal redefinition of symbol: MX_SPI_MOSI_PIN_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(52): Illegal redefinition of symbol: MX_SPI_MOSI_PORT_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(53): Illegal redefinition of symbol: MX_SPI_MOSI_TRIS_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(54): Illegal redefinition of symbol: MX_SPI_MISO_PIN_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(55): Illegal redefinition of symbol: MX_SPI_MISO_PORT_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(56): Illegal redefinition of symbol: MX_SPI_MISO_TRIS_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(57): Illegal redefinition of symbol: MX_SPI_SCK_PIN_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(58): Illegal redefinition of symbol: MX_SPI_SCK_PORT_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(59): Illegal redefinition of symbol: MX_SPI_SCK_TRIS_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(60): Illegal redefinition of symbol: MX_SPI_CS_PIN_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(61): Illegal redefinition of symbol: MX_SPI_CS_PORT_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(62): Illegal redefinition of symbol: MX_SPI_CS_TRIS_X
C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_SPI.c(64): Illegal redefinition of symbol: MX_SPI_PR_SCALE_X

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi !

Is it possible to have a look at this problem ?
Is it possible in flowcode to use components on the same SPI bus ( accelerometer and FAT16 ) ?
I already have my own board with the SPI lines shared between Accelerometer and FAT16 :(

I can write on the SDCARD with your new updated SPI file but impossible to read the acceleremoter ( with old or new SPI file ).
The CS line seems to be always at high level and never down.
If I manually put down the CS line, don't work too :?
And with the two component configured in SPI mode, impossible to compile...

Thank you for your help

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello,

This updated CAL file should fix the compilation errors.
PIC_CAL_SPI.c
(14.28 KiB) Downloaded 334 times
I will look into the Accelerometer and SPI issues and see if I can spot the problem.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Yes, I can compile now !

Recording on SDCARD still works but nothing with the accelerometer. In software or hardware SPI, no way.

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello Mathy,

Can you tell if the Accelerometer CS pin is still staying permanently high?

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Yes, the CS line is always high. If I trig the CS line manually ( High at the top of the program and then, low before a accelerometer macro, high after ), I can see the CS line moving on my oscilloscope screen but still doesn't work.
Maybe I need to introduce delay ?

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi !

I have a scope today !
So I can see on the screen there are some troubles with the accelerometer in SPI mode.

If I compare on the same board the SCK line between configuring FAT component or accelerometer component, the polarity is different ( high with FAT and low with accelerometer ).
The speed seems to be different too but it's difficult to say because the SCK line quality with accelerometer component is very poor. ( but It's OK with FAT component ).
Same thing on the SDO line, the speed seems to be different and the signal quality is very poor when using accelerometer.
SDI doesn't work in accelerometer mode. I think the accelerometer doesn't respond because it understand nothing.

I don't know how I can help you to solve this problem but it would be very cool to me if you could give me temporary workaround of anything else.

Im' using 18F26k22 if it helps !

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

I think I tested all I can to make spi component work but without success...

In hardware SPI, SDO, SDI and SCK seem strange as you can read in my previous post.
CS always high.

In software mode, I have nothing who move...all the line are inactive.

In I2C software mode, works like a charm but I have my SDCARD on the same line who works in SPI.
I have to make it work and I loose lots of time with that.

I can test on real hardware as soon as you give me tips or anything to move on.

Thanks for your time.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi Benj,

Did you have time to look at what happens with your accelerometer component in hardware spi mode ?

Thank your for your help :)

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hello,

I just need to know one thing.
Will you update the accelerometer C file soon ?
Or it is not planned and I have to made an other pcb with a separation of the SDCARD lines and the accelerometer lines ?

I just need to know that and I can go on.

Thank you

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Is there anybody here ?

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello Mathy,

Sorry we are currently a bit flat out at the moment.

Please could you try and customize the defines section of the accelerometer component.

Find the lines that look like this. Note they are not together like shown below.

Code: Select all

#define MX_SPI_PR_SCALE_1		4
#define MX_SPI_PR_SCALE_2		4
#define MX_SPI_PR_SCALE_3		4
#define MX_SPI_PR_SCALE_4		4
and change them to this.

Code: Select all

#define MX_SPI_PR_SCALE_1		16
#define MX_SPI_PR_SCALE_2		16
#define MX_SPI_PR_SCALE_3		16
#define MX_SPI_PR_SCALE_4		16
Hopefully this will resolve the issue.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi,

Thank you for the tips but still don't work.
None of the lines moving ( CS, SCK, SDI or SDO ) in hardware and software SPI mode.

I2C software mode still work like a charm.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Did you have time to look at this problem ?

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hello,

This will soon be one month that I'm stuck.
As I said in this topic, I could remake a board to separate SPI lines of my SDCARD to use accelerometer in I2C mode but you did not answer. It is too late now.
Is it possible to make someone at MM finally fix this function ?

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Should we cry for matrix multimedia fix his bugs ?

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by saschech@gmx.de »

""Steve - who has recently left Matrix - was the sole developer on PPP""

Hello Mathy

I think Steve dont work at Matrix longer and the super sevice bevor go down ...... so I learn c-language with mikroe.It is very hard for me,but
with Training it is better from day to day.Flowcode is mutch easer but my ep-pic-board i can only start with a config file build in mikro-c........

Hope for a better Support for non-eblock System.

Regards Wolfgang

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hi Wolfgang,
""Steve - who has recently left Matrix - was the sole developer on PPP""
Unfortunately Steve has left the company but he has not been responsible for the PPP configs or the level of support provided for a long time. I very much hope that we will continue to provide a very good level of support.

I think the EP problem has been resolved in the latest dsPIC beta. I do all the config files for PPP and I believe I found the bug that was causing you issues. Basically the oscillator clock out option was very misleading so I re-worded it to make more sense and allow you to get the setting correct. I think enabled means that the I/O control was enabled rather then the clock out which is required by the crystal type oscillator setup. If you change this config setting to disabled in your current setup then the config should work correctly. I have an EP device here which works great.

I haven't forgotten about the accelerometer issue and will have a look at fixing it for you today.

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello,

Ok I have tried the Accelerometer component in hardware and software mode on a 16F1939 and it is working great.
1939.jpg
1939.jpg (102.89 KiB) Viewed 12362 times
I dont have the specific device you are using to test with but could you send a copy of your program and I will have a look here and see if there is anything wrong.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi Benj,

Thank you for giving some of your time.
You will find in the attached file the program who give me bad result ( and want to kill myself ).
The SPI lines don't move.

On my computer terminal, the result is 0,0,0.000, so the fuses are good I think.
And, if I change the SPI mode with the software I2C mode, with exactly the same macro, it works.

With the same fuse configuration, I can write on my SDCARD with your FAT32 component in hardware SPI so I think all my hardware is OK.
And when it's writing, I can see the SPI lines moving on my oscilloscope screen so my scope function well to.

Do you have any idea ?
Attachments
BETA V0.01 accel.fcf
(12 KiB) Downloaded 199 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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Hello,

Right I have tried again using your program and a 18F25K22 device.

The hardware SPI pin settings for SPI2 on this device are as follows.

SDI - RB2
SDO - RB3
SCK - RB1

I have also changed the component connections to the following so that all pins are on the same port to aid with testing.

Data available - RB0
Power - RB4
CS - RB5

Doing this my 24MHz scope still cannot pick out all the SPI clock signals though it does appear to be working ok.

Using the custom code feature to drop the prescaler from 4 to 16 gives me this which looks ok.
K22.jpg
K22.jpg (105.31 KiB) Viewed 12353 times
Attachments
BETA V0.01 accel.fcf
(25.04 KiB) Downloaded 204 times

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Problem with Flowcode SPI macro with accelerometer compo

Post by Mathy »

Hi,

Thank you for testing that.
I try your program but without success.

I try with exactly the same pin settings and with mine but still don't work.
CS and CLK don't move.

PIC ----------- LIS3LV02DQ
CS (RA5) --- PIN 13 ( CS )
SDI (RB2) --- PIN 9 ( SDO)
SDO (RB3) -- PIN 10 (SDI)
CLK (RB1) -- PIN 12 (SCL)

Is it possible to send me all the configuration file needed ( 18F26k22 FCD, PIC SPI CAL and accelerometer C file ? )

Thank you for your help.

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: Problem with Flowcode SPI macro with accelerometer compo

Post by Benj »

Here are my files,

Most should be identical to the ones included in v5.4. Any changes will be included in the v5.5 release due out later this month.
FC5_PIC_Accelerometer.c
(15.33 KiB) Downloaded 207 times
PIC_CAL_SPI.c
(14.28 KiB) Downloaded 198 times
18F26K22.fcd
(23.78 KiB) Downloaded 220 times
Let me know how you get on.

Post Reply