Clock config and simple code examples not working

Moderator: Benj

Post Reply
DonM
Posts: 12
Joined: Fri Jul 20, 2012 12:21 am
Has thanked: 14 times
Been thanked: 3 times
Contact:

Clock config and simple code examples not working

Post by DonM »

I am new to using the PIC family of chips and Flow code. My current configuration is:
FCVersion: 5
OS: Win XP SP3
bit: 32
Variant: PIC
I am using PPP v3.12.16.31 with FlowCode 5.1.0.0 (Free)and the Pickit3 with the PICDEM Lab.
Test chip: PIC16F690
I have attached my test code.
Several questions.
1. On some other test code I have tried if I set the oscillator to "Internal RC no clock" the code will not run. If I set it to "XT" as in this code the program runs. I have no external crystal attached to the chip. Why does this work or is the compiler in error?
2. This code should change the state of B4-B7 when A2 changes state. The emulator shows B4-B6 changing state but B7 not changing. The chip only changes B5. Do I have an error in my code or is the compiler introducing errors?

Any help would be appreciated. I would like to use this family of chips and develop on Flow code for a series of products. But I am having trouble getting even the simple things to work.

Thank You
Attachments
Test3.zip
Test program and all associated files.
(84.19 KiB) Downloaded 231 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Clock config and simple code examples not working

Post by dazz »

Hi Don
Had a quick look at your code, if you change the variable pb_7 to a bool then your program seems to work as you wanted, have a look at your config settings and switch off watchdog timer

,let us know how you get on

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi,
Please use the attached program and config setting..
I have added C code for 4MHz internal clock..

Code: Select all

osccon = 0x66;
Hope this will help. :)
Enamul
Attachments
690.JPG
690.JPG (23.24 KiB) Viewed 8677 times
Test3.fcf
(13 KiB) Downloaded 257 times
Enamul
University of Nottingham
enamul4mm@gmail.com

DonM
Posts: 12
Joined: Fri Jul 20, 2012 12:21 am
Has thanked: 14 times
Been thanked: 3 times
Contact:

Re: Clock config and simple code examples not working

Post by DonM »

Thank you for the replies.
I missed PB_7. Changed to BOOL and now the emulator works correctly.
However B5 is still the only output changing on the chip. I assume the "NOT Pulse_In" is correct.
If I change the calculation block to:
NPN_Out = Pulse_In
PB_7 = Pulse_In
PNP_Out = NOT Pulse_In
Rly_Out = Pulse_In

Then PNP_Out (B5) does not change state but the other outputs work.
Any other ideas?

I turned off the watch dog timer and that seems to have corrected the oscillator issue.

Thank you,
Don

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi,
However B5 is still the only output changing on the chip. I assume the "NOT Pulse_In" is correct.
If I change the calculation block to:
NPN_Out = Pulse_In
PB_7 = Pulse_In
PNP_Out = NOT Pulse_In
Rly_Out = Pulse_In
Then PNP_Out (B5) does not change state but the other outputs work.
NOT Pulse_In is fine..
What do you mean by that..is that the pg works in simulation but not in hardware...? Edit:
I have checked that in hardware it's not working...
I am trying to find...
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

DonM
Posts: 12
Joined: Fri Jul 20, 2012 12:21 am
Has thanked: 14 times
Been thanked: 3 times
Contact:

Re: Clock config and simple code examples not working

Post by DonM »

The simulated program works as expected, but the hardware does not. Whatever output is calculated with the "NOT" statement stays ON in hardware.
I hope this clarifies.

Thank you,
Don

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi,
You have rightly spotted the problem. It seems that NOT of bool variable simulates but not work in hardware. I'll post an alternate of that.
Enamul
Last edited by Enamul on Mon Jul 23, 2012 8:28 pm, edited 1 time in total.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi,
I have changed the program to adopt the problem..Basically what I did, I have changed the bool to byte variable..
In the calculation box,

Code: Select all

NPN_Out = (NOT Pulse_In) AND 0x01
PB_7 = (NOT Pulse_In) AND 0x01
PNP_Out = Pulse_In
Rly_Out = (NOT Pulse_In) AND 0x01
For example, Pulse_In = 0x00 //0b00000000
NOT Pulse_In = 0xFF //0b11111111
NPN_Out = 0xFF AND 0x01 = 0x01 //0b00000001
so you managed to toggle first bit..
Similarly, if you have Pulse_In = 0x01 //0b00000001
NOT Pulse_In = 0xFE //0b11111110
NPN_Out = 0xFE AND 0x01 = 0x00 //0b00000000
so output is toggled to 0 at first bit.
Hope this will help. :)
Enamul
Attachments
Test3.fcf
(13 KiB) Downloaded 238 times
Enamul
University of Nottingham
enamul4mm@gmail.com

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Clock config and simple code examples not working

Post by medelec35 »

Just a thought.
Have you tried:

Code: Select all

PNP_Out =! Pulse_In
?
I know ! it's the same thing as NOT.

It maybe worth a try ?

Martin
Martin

DonM
Posts: 12
Joined: Fri Jul 20, 2012 12:21 am
Has thanked: 14 times
Been thanked: 3 times
Contact:

Re: Clock config and simple code examples not working

Post by DonM »

The "PNP_Out = !Pulse_In" works correctly (Logical NOT). Thank you. The ~ and NOT (bitwise NOT) do not function.
Does the Ver. 5.2 Flowcode have this same bug? This seems like such a basic function to not have been found before.

Thank you,
Don

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi,
Does the Ver. 5.2 Flowcode have this same bug? This seems like such a basic function to not have been found before.
This is also true for V5.2. Thanks goes to you and Martin.
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Clock config and simple code examples not working

Post by medelec35 »

No probs.
Tbh I'm not sure it is a bug.
I just found this :
http://www.matrixmultimedia.com/mmforum ... 40&#p33240

@Enamul

You have gone out your way a lot to help people on this forum.

So it should be you that we are thanking :)


Martin
Martin

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Clock config and simple code examples not working

Post by Enamul »

Hi Martin,
Thanks for the link. I have had a quick look at the Boostc manual after your previous post about ! as not. I was thinking the same..
Your last post make us clear from Jonny's clear explanation. Thank you and Jonny.
Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

Post Reply