First PIC Program

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

Moderator: Benj

Post Reply
K9ACT
Posts: 20
Joined: Wed Oct 23, 2013 1:29 am
Been thanked: 1 time

First PIC Program

Post by K9ACT »

I have been hacking around with other people's projects for about 6 months but until today, have never actually written my own program. I was really excited to see my first simple program with Flow Code running on the simulator within an hour of downloading the program.

My joy has subsided since I spent most of the rest of the day trying to get it to run on a real chip.

I started with 16f628a and then 12f675 with the same results.

The program is just output 1, delay, output 0, delay, output 1, delay. Just enough to get a few blinks. I also worked in a loop just to see how it worked but even though they compiled into hex and loaded into the devices, they would not play.

I am using a Pickit 1 with updated firmware. It has worked fine for all my other projects.

I tried various combinations of config bits and clock modes but nothing makes it work.

Totally frustrated with asm and c so I really hope I can get this working.

Any help will be appreciated.

Jack
Marengo, Il

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: First PIC Program

Post by kersing »

Could you upload (attach) one of your programs (the fcfx file) for us to take a look at? It is hard to guess what is wrong from your message.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

K9ACT
Posts: 20
Joined: Wed Oct 23, 2013 1:29 am
Been thanked: 1 time

Re: First PIC Program

Post by K9ACT »

I have attached a file but I note there is also one with a .001 suffix that you might explain.

The good news is that it now runs. I think the problem was trying to run it in the Pickit1 progrm socket. I haven't retried the 628 yet but that was in an off board socket so perhaps something else is going on there.

I also diddled with the config till the code was the same as a known working project so it may have been that too.

But I am having a problem with the delays in this one so I wanted to get back before you all go to bed over there.

The delays in this program don't seem to follow what I tell them to do. Changing from 1 sec to 500 msec or even 100 msec does not have the expected delay. It either changes nothing or stops all together.

The only two device types I have are 12f675 and 16f628 so I can't run any of the tutorial projects.

One other question on that is, why do they all use that odd ball 19 mHz clock freq?

Thanks,

js
Attachments
675.fcfx
(4.22 KiB) Downloaded 276 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: First PIC Program

Post by Benj »

Hello,

The .001 file is a backup of your previous save so you can go back if you need to.

The 19.9908MHz crystal frequency we commonly use is a baud crystal, that means it gives nice round numbers for baud rates such as 9600 and for timer interrupt frequency of 75hz, 150hz, 300hz etc, which are good for timings.

In your configuration settings you have the oscillator set to Internal RC which should be correct for your 4MHz clock speed setting, therefore delays should be working correctly.

I might have a 12F675 here so please can you send a program with delays which is not working correctly for you with details of what's going wrong and I will see if I can get to the bottom of the issue for you.

K9ACT
Posts: 20
Joined: Wed Oct 23, 2013 1:29 am
Been thanked: 1 time

Re: First PIC Program

Post by K9ACT »

Benj wrote:Hello,


In your configuration settings you have the oscillator set to Internal RC which should be correct for your 4MHz clock speed setting, therefore delays should be working correctly.
I just determined that the config settings are ignored in the simulator. Please confirm this.... it would have saved a lot of time to know this.

>I might have a 12F675 here so please can you send a program with delays which is not working correctly for you with details of what's going wrong and I will see if I can get to the bottom of the issue for you.

You don't need the part. Just run the program I sent in simulator and diddle with the delays.

In the meantime, another question. What is the difference between while and until in the loop routine?

That probably give you and idea of my programming knowledge.

Thanks,

js

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: First PIC Program

Post by kersing »

Confirmed: All chip configuration settings are for the device only and are not used in simulation.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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: First PIC Program

Post by kersing »

Regarding While vs Until:

A while executes the loop when the condition is true (not zero).

An until loop executes the loop when the condition is false (zero).
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply