PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

I've been scouring the forums and have most issues resolved, but one major issue remains. After I compile to the chip the program does not run. The program does not seem to execute on the Demo Board despite successful simulation and compile to chip.

Background:
Flowcode V5.1.0.0 (Free/Demo Version)
PK2cmd.exe
Executable Version: 1.20.00
Device File Version: 1.55.00
PICkit 2 Debug Express
PICkit 2 OS Firmware Version: 2.32.00
44-pin Demo Board with PIC16F887

I followed Steve's excellent post regarding the use of PICkit2 with Flowcode V5: http://www.matrixmultimedia.com/support ... f=68&t=787

When I compile to the chip I get the correct output in the compiler messages.
File name: C:\Users\whayden1\Documents\Flowcode\44-pin Labs\Hello World.c
Title:
Description:
Generated by: Flowcode v5.1.0.0
Date: Wednesday, September 11, 2013 01:07:47
Licence: Free version
***FREE/DEMO VERSION***
NOT FOR COMMERCIAL USE
http://www.matrixmultimedia.com
Compilation is up-to-date
Linking is up-to-date
Launching the linker/assembler...
C:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\pk2cmd.exe -B C:\Program Files (x86)\Flowcode\v5\Tools\PICkit2 -PPIC16F887 -F HELLOW~1.hex -M -A5 -R
\ \ \ \ PICkit 2 Program Report
11-Sep-2013, 01:07:48
Device Type: PIC16F887

Program Succeeded.

Operation Succeeded
Return code = 0


FINISHED
Despite no errors the program does not seem to execute on the Demo Board. I wrote a simple "Hello World" just to test. I basically have and LED array which is connected to Port D. I am then turning on D0 in an endless loop. The program works as expected in the simulator, but not on the Demo Board. I have tested the Demo Board in MPLab and it works fine.

Any help is greatly appreciated. I'm at wits end and down trodden.

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

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by dazz »

Hi
Can you attach your flowchart please as it may be something as simple as a connection error, someone had a similar issue a while back and it was just the wrong ports, or a config error, also include a link to the board you are using, as it will make it easier for anyone offering help

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

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

You bet below is a picture of the flow chart. I think this is what you wanted. If not let me know. I'm new to this and your help is greatly appreciated.

The demo board I am using is Microchip's 44-pin Demo Board with a PIC16F887. Link to the user guide here: http://ww1.microchip.com/downloads/en/D ... 41296B.pdf
Link to the chip's datasheet: http://ww1.microchip.com/downloads/en/D ... 41287A.pdf

One thing I did notice and I do think this is a problem I just don't know how to fix it. In Flowcode the PIC16F887 is a 40-PIN PDIP chip (picture left) when in reality is it a 44-PIN QFN (picture right). I have no idea how to change it in flowcode as I only found the chip names "PIC16F887" which is correct. :(
Image Image

Flow Chart
Image

Hoping this is not overkill I provided the C code. I'm still learning so much of this doesn't make sense to me.
//************************************************************************************
//** File name: Flowcode\44-pin Labs\Hello World.c
//** Title: Hello World
//** Description: Basic Hello World program using the mallet approach
//** (ALL LED's ON ALL LED's OFF)
//**
//** Generated by: Flowcode v5.1.0.0
//** Date: Wednesday, September 11, 2013 13:50:10
//************************************************************************************


#define MX_PIC

#define MX_USES_UINT8 1
#define MX_USES_SINT16 0
#define MX_USES_CHAR 0
#define MX_USES_FLOAT 0
#define MX_USES_SINT32 0
#define MX_USES_BOOL 1
#define MX_USES_UINT16 0
#define MX_USES_UINT32 0
//Defines for microcontroller
#define P16F887
#define FC_CAL_PIC
#define MX_ADC
#define MX_ADC_TYPE_7
#define MX_ADC_BITS_10
#define MX_EE
#define MX_EE_TYPE2
#define MX_EE_SIZE 256
#define MX_SPI_1
#define MX_SPI_1_MISO_PORT portc
#define MX_SPI_1_MISO_TRIS trisc
#define MX_SPI_1_MISO_PIN 4
#define MX_SPI_1_MOSI_PORT portc
#define MX_SPI_1_MOSI_TRIS trisc
#define MX_SPI_1_MOSI_PIN 5
#define MX_SPI_1_CLK_PORT portc
#define MX_SPI_1_CLK_TRIS trisc
#define MX_SPI_1_CLK_PIN 3
#define MX_SPI_1_SS_PORT portc
#define MX_SPI_1_SS_TRIS trisc
#define MX_UART_1
#define MX_UART_1_TX_PORT portc
#define MX_UART_1_TX_TRIS trisc
#define MX_UART_1_TX_PIN 6
#define MX_UART_1_RX_PORT portc
#define MX_UART_1_RX_TRIS trisc
#define MX_UART_1_RX_PIN 7
#define MX_I2C
#define MX_MI2C
#define MX_I2C_1
#define MX_I2C_1_SDA_PORT portc
#define MX_I2C_1_SDA_TRIS trisc
#define MX_I2C_1_SDA_PIN 4
#define MX_I2C_1_SCL_PORT portc
#define MX_I2C_1_SCL_TRIS trisc
#define MX_I2C_1_SCL_PIN 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_PSCA1
#define MX_PWM_PSCA4
#define MX_PWM_PSCA16
#define MX_PWM_1_PORT portc
#define MX_PWM_1_TRIS trisc
#define MX_PWM_1_PIN 2
#define MX_PWM_2_PORT portc
#define MX_PWM_2_TRIS trisc
#define MX_PWM_2_PIN 1

//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <pic.h>
#endif

//Configuration data
#ifdef _BOOSTC
#pragma DATA 0x2007, 0x23e2
#endif
#ifdef HI_TECH_C
__CONFIG(0x23e2);
#endif
#ifdef _BOOSTC
#pragma DATA 0x2008, 0x3eff
#endif
#ifdef HI_TECH_C
__CONFIG(0x3eff);
#endif

//Internal functions
#include "C:\Program Files (x86)\Flowcode\v5\FCD\internals.c"

//Macro function declarations


//Variable declarations
#define FCV_FALSE (0)
#define FCV_TRUE (1)

#include "C:\Program Files (x86)\Flowcode\v5\CAL\includes.c"

//Macro implementations

void main()
{
//Initialization
ansel = 0;
anselh = 0;

//Interrupt initialization code
option_reg = 0xC0;

//Comment:
//Hello World

//Loop
//Loop: While 1
while (1)
{

//Output
//Output: 0 -> PORTC
trisc = 0x00;
portc = (0);

//Output
//Output: 0 -> PORTD
trisd = 0x00;
portd = (0);

//Delay
//Delay: 500 ms
delay_ms(255);
delay_ms(245);

//Output
//Output: 255 -> PORTC
trisc = 0x00;
portc = (255);

//Output
//Output: 255 -> PORTD
trisd = 0x00;
portd = (255);

//Delay
//Delay: 500 ms
delay_ms(255);
delay_ms(245);
}

mainendloop: goto mainendloop;
}

void MX_INTERRUPT_MACRO(void)
{
}
Last edited by whayden1 on Wed Sep 11, 2013 8:50 pm, edited 1 time in total.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Hi whayden1,
It looks like the issue is with your configuration settings.
You will need to select 'Build','Project Options.
Click on Configure chip...
Select option for Master Clear Enable and change MCLR is external to RE3 is a digital input.

with a lot of microcontrollers (16F887 included) if set for Master Clear Enable and MCLR line is not connected to +5V (via say 10K resistor)Like in the case of your demo board, then microcontroller will be permanently in the reset state so program will not run.

You have also left your clock speed at 19660800Hz. Crystal on Demo board is 10MHz = 10000000
That will also require changing (Build','Project Options & General Options Tab).

If you have any other issues, can you please post your flowchart which has .fcf extension.
You may also be asked to post your C file which has a .c extension.
whayden1 wrote: One thing I did notice and I do think this is a problem I just don't know how to fix it. In Flowcode the PIC16F887 is a 40-PIN PDIP chip (picture left) when in reality is it a 44-PIN TQFP, QFN (picture right).
No that is not the problem.
You have chosen 16F887 which is correct. They come in different packages, but inside the package is the same electronics circuitry.

Martin
Martin

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

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by dazz »

hi

can you post the FCF file so i can look at config settings etc

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

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Yes sorry. See attachments.

I made the changes to MCLR from external to RE3 is a digital input.
I also changed the oscillator to 10MHz.

When I tried again I get the same result.
Attachments
Hello World.c
(3.38 KiB) Downloaded 253 times
Hello World.fcf
(9 KiB) Downloaded 244 times

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Hi whayden1,
I have corrected flowchart for you.
Your flowchart looked like it was not set the same as in the 1st C code you posted.
For example watchdog timer and low voltage programming was set to enabled but they both should be disabled.
Since clock is greater than 4MHz osc should be set to HS.
Example
whayden1 wrote: #pragma DATA 0x2007, 0x23e2
if you place 0x23e2 in config then your see:
Custom component.png
(60.91 KiB) Downloaded 12669 times
(this is not what it should be set to)



There is more information on this if you follow my signature.

Martin
Attachments
Hello World Config corrected.fcf
(13.5 KiB) Downloaded 256 times
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Martin, thank you very much. I made the changes you suggested.

Project Options > General Options > Configure Chip
Configuration Word(s) > CONFIG was set to 0x23E2

Oscillator: HS
Watchdog Timer: Off
Power Up Timer: On
MCLR: /MCLR is external //** I was told to change this to RC3 is digital input - is this not needed. I tried it both ways just to make sure each time to no avail.
Low Voltage Program: Disabled

Saved and compiled to chip.

Results = nothing

I also tried downloading your corrected example and compiling it to the chip and still nothing.

I am going to go read your post. If anyone has other ideas or thoughts please post. If I figure it out from the post I will update thread.

Again thank you very much.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Hi this should be your configuration settings:
Config settings1.png
(75.82 KiB) Downloaded 12661 times

Sorry if I confused you a bit I was only showing what the c code shown your setting was set to.
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

These are the precise settings I have. Still nothing on the Demo Board.
PICchip Config.JPG
PICchip Config.JPG (74.38 KiB) Viewed 17443 times
I haven't had a chance to read the post you recommended. It's on my list of things to do.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Just to confirm no leds light up?
Have you checked that 5V is being supplied to your board?
Is the 10MHz crystal fitted to the demo board like it shows on the schematic?

The only other thing I can think of is to use the internal oscillator.
Is have done that in the attached flowchart.

Edit I know what the issue is.
I just saw a picture on the net.
The red outline shows crystal and associated components clearly not connected.
The schematic is very misleading:
Demo board.png
(156.9 KiB) Downloaded 12654 times
So your best using the internal oscillator as set up in the attached flowchart.

LEDs connected should then light up.

Martin
Attachments
Hello World internal osc.fcf
(13.5 KiB) Downloaded 230 times
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

The picture you posted is correct there is no external oscillator.

I compiled your file to chip, still no LED's. I suspected this and confirmed that there is no power to the board. My assumption has been this is a setting issue as the PICkit 2 can and perhaps should supply the power and does in MPLab IDE, but not in the PICkit 2 programmer or Flowcode.

Just for clarification I checked for voltage between VDD (supply - pin 3) and VSS (ground - pin 2) on the PICkit 2's ICSP connectors. Voltage for all intensive purposes is 0 VDC.

I guess I could power the board via external power supply. This is what I am going to try next.

So I just connected my PR-503 Proto-Boards power supply to the main supply of the Demo Board and I have LED's! "Hello World! I'm Alive, I'm Alive!!!"

Questions:
Should I just opt for this route (power board from external source)? If I do I assume this will not harm the PICkit2 if I leave it connected since it is designed to be an in circuit programmer/debugger.
Or should the PICkit2 supply this voltage via some magical setting? This at least up to now has been my assumption, but again this is still my first 24 hours of messing with this stuff.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Hi whayden1,
Since you have no external crystal then you can't use HS (High Speed clock)
It has to be internal oscillator or External RC of you have a correct external components (Resistor and capacitor) connected. I would not recommend the latter.

I believe you can keep the power supplied to target device by using -T switch so for 32bit you can try:
-BC:\Program Files\Flowcode\V5\Tools\PICkit2\ -PPIC%p -F%f.hex -M -A5 -R -T

I'm not 100% sure so if it does not work I can try when I get home from work this evening.
If you do use pickit2 to supply demo board then the maximum current Pickit2 can supply is 30mA

You can use an external power supply to supply demo board even during programming which is probably the better option
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Thanks Martin. I agree, I'm consigned to using the external power supply at this point. I went ahead and installed a header on my demo board allowing me to easily connect/disconnect it to my DC supply. I had no problems with the board's or PIC's operation during programming or running with the power supply connected.

That being said I am still going to try the -T option. Not sure how I overlooked that one in the list of available options. Seems self evident. Perhaps it was because my head was swimming in the ocean of information overflow. There's definitely a lot more to this than I originally anticipated and I by no means thought it would be a walk in the park. At any rate I plan to enjoy the journey.

I truly appreciate you taking the time to help this noob out.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

whayden1 wrote:I truly appreciate you taking the time to help this noob out.
Your welcome.
We have all been there.
When your ready to learn some more the Learning centre is a great place to visit:
http://www.matrixmultimedia.com/lc_index.php?p=24
There is a free online course for learning about Flowocde.

Most important just have fun!
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Just for the record I tried the -T option. It had no effect. I'm resolved to just use the external power supply.

Thanks for the link to the learning center. Goal one is to read the 44-pin Demo Board User Guide and Lessons. I stop over to the Learning Center next.

Cheers!

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

Hi whayden1,
whayden1 wrote:Just for the record I tried the -T option. It had no effect.
Odd since I can confirm

Code: Select all

-BC:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\ -PPIC%p -F%f.hex  -M -A5 -R -T 
Does keep target powered up for me.

It maybe you have a different firmware version in your PICkit2.
Here is something to try:
At the end of -BC:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\ -PPIC%p -F%f.hex -M -A5 -R -T just place /?
So you have got -BC:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\ -PPIC%p -F%f.hex -M -A5 -R -T /?
Then program to chip.
You should get all the switches displayed:

Code: Select all

Launching the programmer...
C:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\pk2cmd.exe -BC:\Program Files (x86)\Flowcode\V5\Tools\PICkit2\ -PPIC16F887 -FReversible Variable Speed Rotate.hex  -M -A5 -R -T /?
                        PICkit 2 COMMAND LINE HELP
Options              Description                              Default
----------------------------------------------------------------------------
A<value>             Set Vdd voltage                          Device Specific
B<path>              Specify the path to PK2DeviceFile.dat    Searches PATH
                                                              and calling dir
C                    Blank Check Device                       No Blank Check
D<file>              OS Download                              None
E                    Erase Flash Device                       Do Not Erase
F<file>              Hex File Selection                       None
G<Type><range/path>  Read functions                           None
                     Type F: = read into hex file,
                             path = full file path,
                             range is not used
                     Types P,E,I,C: = ouput read of Program,
                             EEPROM, ID and/or Configuration
                             Memory to the screen. P and E
                             must be followed by an address
                             range in the form of x-y where
                             x is the start address and y is
                             the end address both in hex,
                             path is not used
                             (Serial EEPROM memory is 'P')
H<value>             Delay before Exit                        Exit immediately
                         K = Wait on keypress before exit
                         1 to 9 = Wait <value> seconds
                                  before exit
I                    Display Device ID & silicon revision     Do Not Display
J<newlines>          Display operation percent complete       Rotating slash
                         N = Each update on newline
K                    Display Hex File Checksum                Do Not Display
L<rate>              Set programming speed                    Fastest
                     <rate> is a value of 1-16, with 1 being
                     the fastest.
M<memory region>     Program Device                           Do Not Program
                     memory regions:
                         P = Program memory
                         E = EEPROM
                         I = ID memory
                         C = Configuration memory
                         If no region is entered, the entire
                         device will be erased & programmed.
                         If a region is entered, no erase
                         is performed and only the given
                         region is programmed.
                         All programmed regions are verified.
			            (serial EEPROM memory is 'P')
N<string>            Assign Unit ID string to first found     None
                     PICkit 2 unit.  String is limited to 14
                     characters maximum.  May not be used
                     with other options.
                     Example: -NLab1B
P<part>              Part Selection. Example: -PPIC16f887     (Required)
P                    Auto-Detect in all detectable families
PF                   List auto-detectable part families
PF<id>               Auto-Detect only within the given part
                     family, using the ID listed with -PF
                     Example: -PF2
Q                    Disable PE for PIC24/dsPIC33 devices     Use PE
R                    Release /MCLR after operations           Assert /MCLR
S<string/#>          Use the PICkit 2 with the given Unit ID  First found unit
                     string.  Useful when multiple PICkit 2
                     units are connected.
                     Example: -SLab1B
                     If no <string> is entered, then the
                     Unit IDs of all connected units will be
                     displayed.  In this case, all other 
                     options are ignored. -S# will list units
                     with their firmware versions.
                     See help -s? for more info.
T                    Power Target after operations            Vdd off
U<value>             Program OSCCAL memory, where:            Do Not Program
                      <value> is a hexadecimal number
                      representing the OSCCAL value to be
                      programmed. This may only be used in
                      conjunction with a programming 
                      operation.
V<value>             Vpp override                             Device Specific
W                    Externally power target                  Power from Pk2
X                    Use VPP first Program Entry Method       VDD first
Y<memory region>     Verify Device                            Do Not Verify
                         P = Program memory
                         E = EEPROM
                         I = ID memory
                         C = Configuration memory
                         If no region is entered, the entire
                         device will be verified.
                         (Serial EEPROM memory is 'P')
Z                    Preserve EEData on Program               Do Not Preserve
?                    Help Screen                              Not Shown

     Each option must be immediately preceeded by a switch, Which can
     be either a dash <-> or a slash </> and options must be separated
     by a single space.

     Example:   PK2CMD /PPIC16F887 /Fc:\mycode /M
                               or
                PK2CMD -PPIC16F887 -Fc:\mycode -M

     Any option immediately followed by a question mark will invoke
     a more detailed description of how to use that option.

     Commands and their parameters are not case sensitive. Commands will
     be processed according to command order of precedence, not the order
     in which they appear on the command line. 
	Precedence:
                -?      (first)
                -B
                -S
                -D
                -N
                -P
                -A -F -J -L -Q -V -W -X -Z
                -C
                -U
                -E
                -M
                -Y
                -G
                -I -K
                -R -T
                -H      (last)
		
     The program will return an exit code upon completion which will
     indicate either successful completion, or describe the reason for
     failure. To view the list of exit codes and their descriptions,
     type -?E on the command line.

     type -?V on the command line for version information.

     type -?L on the command line for license information.

     type -?P on the command line for a listing of supported devices.
     type -?P<string> to search for and display a list of supported devices
                      beginning with <string>.

     Special thanks to the following individuals for their critical
     contributions to the development of this software:
		Jeff Post, Xiaofan Chen, and Shigenobu Kimura

Operation Succeeded
Return code = 0

FINISHED

Just for the demo board I have created a flowchart that will rotate LED's in one direction until SW is pressed, then will cause LED's to rotate in the reverse direction.
Using interrupt method since the switch is connected to INT (Edge triggered Interrupt pin RB0)

The ADC component is used to change speed of chasing LED's

Martin
Attachments
Reversible Variable Speed Rotate.fcf
(17 KiB) Downloaded 205 times
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Wonderful program Martin! I had to back up a few paces nothing was working yesterday and I was just dog tired so I said forget it to everything.

I'm back up and running today taking things slow and one step at a time. For whatever reason my chip settings reverted back to their original state. I thought the chip settings were saved in the flowchart. If they are something else happened. After I set the chip back up the way we discussed it started working again.

I'll have to run through this a bit more. I tried the -T and it still didn't power the board, but agree that it should. From what I gather you have this same board and PICkit and were able to confirm in your setup? If so either I have an issue with my PICkit or demo board. I bought it off Ebay "listsed as new" and it was clearly not new. The proto area has jumpers and LED's soldered to it. They work I tested them, but it wasn't the best workmanship, though this shouldn't be a problem in of itself.

Question, is it possible to have say Port D and Port C doing separate things (parallel processing)? The programming in Flowcode appears to be linear. What I mean can I have say PortC's LED's flashing at one rate and PortD's LED's flashing at a different rate. Or LED's 0-3 on PortD flashing at one rate and style and LED's 4-5 on PortD flashing at a different rate/style? I haven't been able to find any examples or info stating yes or no.

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

whayden1 wrote:Wonderful program Martin! I
Thanks.
whayden1 wrote:I thought the chip settings were saved in the flowchart
Yes they should be.
whayden1 wrote: From what I gather you have this same board and PICkit and were able to confirm in your setup?
Yes I have the same board and Found it yesterday :) It has has been lost for a very long time. I have got version:
Pickit2 Version.png
(16 KiB) Downloaded 12550 times
You may need to update your pickit2 firmware?
Did you try the /? trick I mentioned?

.
whayden1 wrote: Or LED's 0-3 on PortD flashing at one rate and style and LED's 4-5 on PortD flashing at a different rate/style?
Yes this is a bit more advance but it can be done.
Your be amazed at some of the things that can be achieved. It's just a matter of learning how to do it.
whayden1 wrote: it possible to have say Port D and Port C doing separate things (parallel processing)?
With microcontrollers one line of code is executed at a time but since the speed each instruction is carried out it looks like its all multitasking.
If you tun on port C then 1ma later turn on port D, it looks like both ports were turned on at exactly the same time.

Martin
Martin

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

whayden1 wrote:LED's 0-3 on PortD flashing at one rate and style and LED's 4-5 on PortD flashing at a different rate/style? I
I have done that in the attached Flowochart.
I have used the timer interrupt to do the timing of the flashing.
Since all the routine is within timer0 interrupt macro.
As a rough guide on how timer0 interrupt works:
Timer0.png
(108.36 KiB) Downloaded 12536 times
Interrupt Frequency is set by selecting 'Prescaler Rate'
In this case since prescaler is 1:64 the interrupt frequency is 61.035Hz (note this is based on a clock of 4MHz)
This simply means that the timer0 internal register will overflow every

Code: Select all

1/61.035 = 16.38ms   (milliseconds)
It is this overflow that caused the timer0 macro to be accessed.
So every 16.38 ms:

Code: Select all

CountPortDHigh = CountPortDHigh + 1
CountPortDLow = CountPortDLow + 1
Since there is

Code: Select all

 If CountPortDHigh = 15
then every 16.38 x 15 = 245.7ms the Higher bits (4 to 7) change state.
With

Code: Select all

If CountPortDLow = 61
Then every 16.38 x 61 =999.1ms (very nearly 1second) the lower bits (0 to 3) change state.
Attachments
Variaing pin rates.fcf
(15.5 KiB) Downloaded 202 times
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Martin,

I can't wait to check the variaing pin rates program out! I wanted to provide a response to your earlier question on versions. My PICKit OS and Microchip apps are all fully updated. This was the first thing I did when I received the unit.

I noticed something very strange the other night. I hope I can explain it clearly. So you know we've been testing the -T option. It didn't seem like it was doing anything. The 44-pin Demo Board would not operate unless I have it connected to an external PS. So the other night I was messing around and I turned off my external PS which is on my PB-503. I also have a number of LED's on my PB-503's breadboard connected to the supply which are for the circuit I eventually plan to build using a PIC16F84A. When I turned the PB-503 off all the LED's on the PB-503's breadboard were still lit up. I was like huh? Well it was the PICkit2 that was providing the power through the 44-pin Demo Board. Unplug the PICkit all LED's on the PB-503 went out. Plug it in and they all came on. So the PICkit is supplying power, but why the 44-pin Demo Board does not come on is very strange. I tried disconnecting the LED circuits on the PB-503 which had no effect.

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Correction after perusing the 16F84A datasheet I see it has no internal osc. I was going to use it because I have one on hand and it's the right size with enough I/O ports for the task at hand. Reading around I found a recommendation to use the 16F628A instead which is pin compatible, which I don't really care about. What I like is the small package size and low pin count. It also has two INTOSC options 4Mhz and 48Khz. I like the idea of an INTOSC as it just makes things cleaner, less expensive and less complicated. I don't need precise timing as all I'm doing is lighting LED's. Most (6 LEDs) will be steady on with 2 LED's toggling on/off (flip/flop) and one toggling or preferably pulsing on/off. Ideally the later will be pulsing at a different rate as the 2 flip flops. Hence my previous question and your example.

I'd also like to have an switch tied to one of the solid on LED's. Press to turn LED's on/off. This could be accomplished with a simple SPST switch in series with the LED, but the idea of an interrupt is much grander and within the capabilities of the chip, just not mine. :lol:

This will all be powered by a 4 AA 6V battery pack, with a master SPST switch to turn the unit on/off.

Thoughts?

Microchip PIC16F628A: http://ww1.microchip.com/downloads/en/D ... 40044G.pdf

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: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by medelec35 »

That will be easily achievable with Flowcode.
See how far you can get.
If you get stuck just yell.

Martin
Martin

whayden1
Posts: 12
Joined: Wed Sep 11, 2013 6:51 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: PICkit 2 w/ Flowcode V5 - Prog does not execute on chip

Post by whayden1 »

Thanks will do. I have a basic flow code worked out. It at least gets me the solid on and flashers. Just need to update it for the 16F628A. What I don't have working yet is the pulsing LED. If I recall this requires the PWM function, which I haven't figured out or the button interrupt. I'll continue my research.

I thank you very much for all your help.

William

Post Reply