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

Dutch
Posts: 50
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 20 times
Been thanked: 3 times
Contact:

Trying to get a C code in

Postby Dutch » Mon Jun 01, 2015 7:01 pm

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.39 KiB) Downloaded 377 times
Last edited by Dutch on Mon Jun 01, 2015 7:07 pm, edited 1 time in total.

Dutch
Posts: 50
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 20 times
Been thanked: 3 times
Contact:

Re: Trying to get a C code in

Postby Dutch » Mon Jun 01, 2015 7:05 pm

here a screenshot of the code i placed in a block..

Knipsel.JPG
Knipsel.JPG (80.43 KiB) Viewed 6380 times

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Trying to get a C code in

Postby kersing » Mon Jun 01, 2015 7:13 pm

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.
These users thanked the author kersing for the post:
Dutch (Mon Jun 01, 2015 7:28 pm)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Dutch
Posts: 50
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 20 times
Been thanked: 3 times
Contact:

Re: Trying to get a C code in

Postby Dutch » Mon Jun 01, 2015 7:26 pm

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: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Trying to get a C code in

Postby Benj » Tue Jun 02, 2015 2:11 pm

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: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Trying to get a C code in

Postby kersing » Tue Jun 02, 2015 9:35 pm

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
These users thanked the author kersing for the post (total 2):
medelec35 (Tue Jun 02, 2015 10:02 pm) • Benj (Wed Jun 03, 2015 9:41 am)
Rating: 10.53%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis