Page 1 of 1
Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 4:19 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 4:46 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 5:21 pm
by Enamul
Hi,
Please use the attached program and config setting..
I have added C code for 4MHz internal clock..
Hope this will help.
Enamul
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 5:47 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 5:57 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 6:03 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 6:29 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 8:12 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 8:51 pm
by medelec35
Just a thought.
Have you tried:
?
I know ! it's the same thing as NOT.
It maybe worth a try ?
Martin
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 9:13 pm
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
Re: Clock config and simple code examples not working
Posted: Mon Jul 23, 2012 10:18 pm
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
Re: Clock config and simple code examples not working
Posted: Tue Jul 24, 2012 12:02 am
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
Re: Clock config and simple code examples not working
Posted: Tue Jul 24, 2012 12:30 am
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