Trying to get a C code in

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times

Trying to get a C code in

Post by Dutch »

Hi, i am still a novice in pic devices. i made a few nice projects but not the level i have a question about. i am looking for a way to put a exsiting c code in a C-block into Flowcode. i'm using a pic16F88. i searched a weekend and evenings on the net and watched many examples in the tutorials but i cant get it done. it looks like it is written in a 'old' style code (i think) but i found the exact same way of older exactly the same written examples on the microchip site. this freeware project is from 2007 and i cant contact the Original writer. i changed lines and removed and/or changed the remark from ; to // but nothing works. the codes look plausible to me... i can find a lot of it back in the datasheet.
I have the text file of the c code and i borrowed a working processor from someone in the USA i need to ship back eventually. i want to make a working copy first and if i get it working i can search in the c code for changes to make because i want to adapt it and also learn in that way to understand C better. i wished i'm that good yet to convert it into a flowcode :( .
I cant simply copy the Original pic (and is not as much fun) because the writer did put the MCLR as internal and my PICKIT3 programmer warns i cannot use this function in collaboration with a other function.

My last resort is to ask it..really... hope i find a enthusiast here that can find or point out what i'm doing wrong.
Thanks!

here a small piece of the code. i took most lead comments off...
The comments i placed // before the ;
The ERRORLEVEL i cant find in the datasheet.
GPI original.txt
(3.32 KiB) Downloaded 706 times
Last edited by Dutch on Mon Jun 01, 2015 7:07 pm, edited 1 time in total.

Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times

Re: Trying to get a C code in

Post by Dutch »

here a screenshot of the code i placed in a block..
Knipsel.JPG
Knipsel.JPG (80.42 KiB) Viewed 14041 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: Trying to get a C code in

Post by kersing »

This is not C code so embedding it in a C code block will not work. The code only contains chip settings and variable declarations in assembly, no instructions to execute.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times

Re: Trying to get a C code in

Post by Dutch »

Thanks Kersing :? :wink:
the total is a text of 1000 lines comments included. so what can i do with this 'assembly' text

can i somhow convert it?

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: Trying to get a C code in

Post by Benj »

Hello,

I would suggest that you spend some time with the code and then replicate using Flowchart icons. Flowcode should do a lot of the heavy lifting so for example you can use one of the ADC components rather then trying to talk directly to the ADC registers like the assembler is doing.

Your ambient RAM block looks ideal for use with an array variable.

If you want to use the assembler then you can wrap assembler code inside a C icon like this.

asm
{
ASM CODE
ASM CODE
ASM CODE
}

Note that the Flowcode program is already past the ORG 0 reset vector point when you call the C icon so your definitions etc from your current assembler commands might cause issues.

If you want to simply compile the ASM program as is then why not use the free Microchip MPASM compiler?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: Trying to get a C code in

Post by kersing »

Hi Ben,

We continued the conversation in (dutch) PMs. The code is assembly for MPASM, as I have an older version of it around I generated HEX code.

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply