Difference between revisions of "One second LED flasher"

From Flowcode Help
Jump to navigationJump to search
Line 32: Line 32:
 
For an 16-bit PIC device a crystal oscillator below 10MHz is the XT option, 10MHz or above is the HS option.
 
For an 16-bit PIC device a crystal oscillator below 10MHz is the XT option, 10MHz or above is the HS option.
  
Internal clock speeds will vary depending on your device and may need a C code icon at the start of your program to configure them correctly to the frequency you require.
+
Internal clock speeds will vary depending on your device and may need a C code icon at the start of your program to configure them correctly to the frequency you require. The [INTOSC Helper|Component:_IntOsc_Helper_(Matrix_Tools)] component will help you determine the required C code.
 
 
  
 
==AVR Specific==
 
==AVR Specific==

Revision as of 11:08, 9 October 2017

If Flowcode is mis-configured for your hardware then time dependent code such as delays, communication bauds, timers etc. will fail to run as intended. A very simple way of confirming your hardware is configured correctly in Flowcode is with the use of a one second flasher program.


The one second flasher program simply consists of a loop, a couple of delays and a couple of output icons. The idea is to switch an output pin on and off to which a LED and series resistor (200R - 1K) can be attached to confirm if the delays are approximately equal to a second. The likelihood is that the delays will be either bang on one second or will be way out confirming there is a configuration issue.


Here is a example of a one second flasher program.

OneSecFlash.jpg


If the delays on the hardware do not equal one second or the LED does not flash at all then here are some areas to check.


Is the Project Options project clock speed setup correctly for your oscillator source? This value can be selected from the drop down list or typed in directly to allow for any oscillator speed.

ClockSpeed.jpg


Is the Project Options configuration setup correctly for your oscillator source? These settings will vary from device to device so it is often necessary to refer to the device datasheet for details on specifics.

Config.jpg


Generally speaking the Watchdog timer, Low Voltage Programming and Extended CPU settings should all be set to disabled unless you specifically need the functionality they provide.


PIC Specific

For an 8-bit PIC device a crystal oscillator below 4MHz is the XT option, 4MHz or above is the HS option.

For an 16-bit PIC device a crystal oscillator below 10MHz is the XT option, 10MHz or above is the HS option.

Internal clock speeds will vary depending on your device and may need a C code icon at the start of your program to configure them correctly to the frequency you require. The [INTOSC Helper|Component:_IntOsc_Helper_(Matrix_Tools)] component will help you determine the required C code.

AVR Specific

AVR hardware has a divide by 8 configuration setting which can often be enabled by default, e.g. if your 1 second delay is lasting 8 seconds.

Do not disable the SPI clock in the AVR configuration as this will effectively disable the serial programming interface used by the AVRISP mkII and TinyISP etc.

Arduino devices should come pre-programmed with the right configuration settings and bootloader. The serial interface is required to re-program the bootloader if required.