Flowcode - FCD #C Help

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

Moderator: Benj

Post Reply
johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Contact:

Flowcode - FCD #C Help

Post by johnsondav »

Hi Everyone.
I would like to know, if someone could point me the right direction to find the information/help that I need for this project I am working on. Maybe a book I need to read or Wiki page to look at, to give me the following information:
- How to incorporate chip specific code to change PIC (8bit) registers i. e. SSPCON1; SSPCON2 etc
- example of C code to achieve the changes
- do's and don'ts

I am not looking for the actual answers, just how or where do I look to learn how it's done. I am working on a project to read Ink jet printer cartridges. These have a very odd I2C protocol that I cannot replicate from the standard FC components. I need to change things like clock polarity at will during data transfers/addressing to get it to work.

Any suggestions would be greatly appreciated. I have looked at a previous forum post on this subject and to be honest, I do not fully understand the #C language others are using. A good book which relates to this topic is what I think I am looking for. Any ideas/suggestions pls.

I do know it can be done as others have achieved it using Arduino sketches, which again, I am not able to follow just yet.

User avatar
Benj
Matrix Staff
Posts: 15147
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Flowcode - FCD #C Help

Post by Benj »

Hello,

There are likely books on the xc compilers available. I started a book on flowcode for flowcode v5 which is available on the forums somewhere but is a bit out of date now.

viewtopic.php?f=54&t=14238&p=56468&hili ... ook#p56436

The easiest way to write a reg is using a c icon.

E.g.

SSPCON1 = 0b01011100;

You can also modify individual register elements using the dot notation.

E.g.

REGISTERbits.BITNAME = 0b11;

Or

SSPCON1bits.EN = 1;

The datasheet lists all the registers and register elements but you pragmatically find the structures defined in the device header file located within the compiler files.

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Contact:

Re: Flowcode - FCD #C Help

Post by johnsondav »

Hi Ben

Thank for the info and book, it's very much appreciated. I have seen the header files you mention with the Microchip MPLAB files, but I am unable to locate these files within FC. However, I like the suggestion you have provided on how to change individual register bits, this is exactly what I am looking for. This will give me plenty of scope for experimentation Thank You.

Dave

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Contact:

Re: Flowcode - FCD #C Help

Post by johnsondav »

Hi Everyone
I have been looking for some detailed information as to how to build a communication protocol to send/receive data to/from ink cartridges. The protocol is, as I have now concluded is more aligned to the SPI than I2C protocol, as there are no ack bits in the data collected from the cartridge chip. So, I need to use C programming (I think) to get this project working. Here is a useful link to free online books:
http://www.allitebooks.in/

There are some good books on offer (free) in pdf format do download.

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Contact:

Re: Flowcode - FCD #C Help

Post by johnsondav »

Hi Everyone

I just want to share this with you. I have been trying to get to grips with FC7 & 8 C code environment. I have discovered that, by simply clicking onto and dragging the variable across into the C icon space creates the correct syntax. And it compiles correctly too.
FC7
C code generation.jpg
C code generation.jpg (133.28 KiB) Viewed 1337 times
FC8
C code generation FC8.jpg
(102.07 KiB) Downloaded 873 times

Post Reply