Using STK500 with Flowcode

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Using STK500 with Flowcode

Post by TomasS »

Hi

I am a newbe using Flowcode and would like to use an STK500 as platform. But how do I setup Flowcode to use the STK500? Should I connect an AVRISP MKII to the ISP connector on the STK500 or should I use a USB to RS232 converter and connect to the DP9-connector?

I hope there is a helpful person in here, that can guide me a little, so I can continue using this great tool 8)

BR

Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

Hello Tomas,

If you already have an AVRISPmkII working from Flowcode, you can simply connect it to the ISP connector of the STK500 board, which can then be used as a target/development board without any changes to settings.

The STK500 can be used direcly, via RS232, by changing the communications option in the Programmer: Parameters: section of the Chip -> Compiler Options menu, from USB to comx (where x is the ID of the COM port being used). This has only been tested using PCs with legacy COM ports - not using a USB to RS232 converter.

If you are using the STK500/COM option, via the AVRDUDE programming utility, the various programming modes can be selected using different programmer names:

stk500v2 (serial programming mode)
stk500hvsp (high voltage serial programming mode)
stk500pp (parallel programming)

It might be a good idea to check on the devices supported by each programmer before selecting your prefered option.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

Hi Sean
sean wrote:If you already have an AVRISPmkII working from Flowcode, you can simply connect it to the ISP connector of the STK500 board, which can then be used as a target/development board without any changes to settings.
I have an AVRISPmkII, but tried connecting it to the ISP port SPROG2 on
Image
But the LED on the mkII flashes red, indicating no contact to the uC. (I have placed an ATmega8 in the green socket as the ATmega168 shown above).
sean wrote:The STK500 can be used direcly, via RS232, by changing the communications option in the Programmer: Parameters: section of the Chip -> Compiler Options menu, from USB to comx (where x is the ID of the COM port being used). This has only been tested using PCs with legacy COM ports - not using a USB to RS232 converter.
I want to use flowcode and the STK500 for education (Technical college) - Earlier I used C-programming teaching microcontrollers, but from a time point-of-view it's a problem using C since the time is limited - therefor I would like to use Flowcode. The problem is that no new laptops has a serial port today - so no of the students can use a serial port for the STK500.
sean wrote:If you are using the STK500/COM option, via the AVRDUDE programming utility, the various programming modes can be selected using different programmer names:

stk500v2 (serial programming mode)
stk500hvsp (high voltage serial programming mode)
stk500pp (parallel programming)

It might be a good idea to check on the devices supported by each programmer before selecting your prefered option.
Until now I have only used Flowcode via E-blocks

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

Re: Using STK500 with Flowcode

Post by medelec35 »

TomasS wrote:The problem is that no new laptops has a serial port today - so no of the students can use a serial port for the STK500.
Just a thought. Would either a USB to RS232 serial lead or a RS232 Bluetooth adaptor work?
I don't believe every lead works with every application.
This has something to do with RS232 Voltages, but maybe worth a try?

I cannot vouch for this company since never used them, but to give you an idea:
http://www.usbnow.co.uk/Adapters_&_Conn ... 4wodA2ikqg
Martin

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: Using STK500 with Flowcode

Post by Benj »

Hello

Are you powering the board when you try to program the device. The AVRISPII device should light up green when all of the connections are ok and the board is powered up. A red LED may also suggest a back to front ISP header on the board.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

Benj wrote:Hello

Are you powering the board when you try to program the device. The AVRISPII device should light up green when all of the connections are ok and the board is powered up. A red LED may also suggest a back to front ISP header on the board.
Hi Benj

When the AVRASPmkII is connected to the STK500 unpowered, nothing happens, but turning the power on makes the status LED flash orange-red. When I then turn of the power again, the LED now is constant red. I tried to turn the connector, but after downloading, it just flashes red whith a faster rate.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

medelec35 wrote:
TomasS wrote:The problem is that no new laptops has a serial port today - so no of the students can use a serial port for the STK500.
Just a thought. Would either a USB to RS232 serial lead or a RS232 Bluetooth adaptor work?
That was my immediate idea, but I hoped someone could confirm that it does..
medelec35 wrote:I don't believe every lead works with every application.
This has something to do with RS232 Voltages, but maybe worth a try?
Maybe - I will give this link a try:
medelec35 wrote:I cannot vouch for this company since never used them, but to give you an idea:
http://www.usbnow.co.uk/Adapters_&_Conn ... 4wodA2ikqg

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: Using STK500 with Flowcode

Post by Benj »

turning the power on makes the status LED flash orange-red. When I then turn of the power again, the LED now is constant red. I tried to turn the connector, but after downloading, it just flashes red whith a faster rate.
Sounds like a back to front or incorrect connector to me. Have you a multimeter that you can use to check that the ISP connections are correct.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

I have now successfully downloaded a program directly from Flowcode to an STK500 target board, using the AVRISPmkII programmer.

The only problem with my standard setup was the presence of the RESET jumper. This needs to be removed to allow the ISP programmer to take control of the RESET line - otherwise the on-board programmer has control of the line.

The ISP programming connector needs to be plugged onto the SPROG2 connector the correct way round - as indicated by the markings on the pcb and connector.

The Atmega8 needs to be in the SCKT3200A2 socket.

The oscillator jumpers also need to be set correctly to provide the required master clock signal.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

sean wrote:I have now successfully downloaded a program directly from Flowcode to an STK500 target board, using the AVRISPmkII programmer.

The only problem with my standard setup was the presence of the RESET jumper. This needs to be removed to allow the ISP programmer to take control of the RESET line - otherwise the on-board programmer has control of the line.

The ISP programming connector needs to be plugged onto the SPROG2 connector the correct way round - as indicated by the markings on the pcb and connector.

The Atmega8 needs to be in the SCKT3200A2 socket.

The oscillator jumpers also need to be set correctly to provide the required master clock signal.
Hi Sean
Problem solved! It was simply the jumper that caused the problem. Now I am able to download the HEX-file. However, the program I have made is a simple running LED-program: LED0 and LED7 is on then LED1 and LED6 and so on, returning backwards when meeting at LED3 and LED4. In the simulation it runs fine, but on target 4-5 LEDs are turned on and changes in a strange patern - It doesn't make sence.
Would it be ok to send my application to you, so you can try it out and check if it runs normal on your kit?

BR
Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

Can you send a zip folder contaning the .fcf_avr file and the .c file created by Flowcode?

I will also need to know the configuration fuse values you are using. Have these been re-programmed from Flowcode, or are they the default values set by the manufacturer - which need to be changed.

I sent the following fuse settings to the Atmega8 from the Chip -> Config menu panel in Flowcode:

0x0,0xdf
0x1,0xff

<Ok and send>

These settings ensure that unused system and debug functions are disabled, and the external crystal is selected as the clock source.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

sean wrote:Can you send a zip folder contaning the .fcf_avr file and the .c file created by Flowcode?

I will also need to know the configuration fuse values you are using. Have these been re-programmed from Flowcode, or are they the default values set by the manufacturer - which need to be changed.

I sent the following fuse settings to the Atmega8 from the Chip -> Config menu panel in Flowcode:

0x0,0xdf
0x1,0xff

<Ok and send>

These settings ensure that unused system and debug functions are disabled, and the external crystal is selected as the clock source.
Hi Sean

I have sent you a PM with the files.

BR.
Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

I have downloaded and tested your program. It is runnung correctly on my system, but the results displayed on the leds initially appear to be confusing. There are 2 reasons for this:

The STK500 leds are commoned to the positive supply voltage, so a high level on a port pin will turn the connected led off (low = on). Flowcode V3 simulation assumes that leds are commoned to 0V (high = on). Flowcode V4 simulation supports individual leds that can be active high or low.

Port B pins 6 and 7 are not available when using an external crystal. These pins are used as the XTAL1 and XTAL2 connections, and can only be used if the device is configured to be run from its internal oscillator. Port D is the only one that is fully available in external crystal mode.

I inverted the data in your array, and moved the outputs to Port D. The results are probably what you were expecting.

light[0] = 126
light[1] = 189
light[2] = 219
light[3] = 231

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

sean wrote:I have downloaded and tested your program. It is runnung correctly on my system, but the results displayed on the leds initially appear to be confusing. There are 2 reasons for this:

The STK500 leds are commoned to the positive supply voltage, so a high level on a port pin will turn the connected led off (low = on). Flowcode V3 simulation assumes that leds are commoned to 0V (high = on). Flowcode V4 simulation supports individual leds that can be active high or low.

Port B pins 6 and 7 are not available when using an external crystal. These pins are used as the XTAL1 and XTAL2 connections, and can only be used if the device is configured to be run from its internal oscillator. Port D is the only one that is fully available in external crystal mode.

I inverted the data in your array, and moved the outputs to Port D. The results are probably what you were expecting.

light[0] = 126
light[1] = 189
light[2] = 219
light[3] = 231
I knew about the STK500 been active low on the output since the outputs are pulling the Emitters low on the driver transistors, but the problem on the XTAL-connections I wasn't aware of - It is running as expected now! Thank You!

But since I am not using an external XTAL - a setting must be wrong. What do I need to change to be able to use the PB6 and 7 as normal I/O?

BR.
Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

The fuse settings I sent previously were to configure the chip to run from an external XTAL source - the one on the STK500 board.

The option to allow use of Port B 6/7 is to run from the internal calibrated RC oscillator. The fuses can select operation from the internal oscillator at 1, 2, 4 and 8 MHZ.

The first fuse value is 0xdf for all options. The second fuse setting is frequency dependent, 0xe1 = 1MHz, 0xe2 = 2MHz, 0xe3 = 4MHz, 0xe4 = 8MHZ.

Example fuse settings to run an Atmega8 from the internal oscillator at 8MHz:

0x0,0xdf
0x1,0xe4

Unfortunately, it would appear that the STK500 board does not track Port B pin 6/7 from the SCKT3200A2 socket to the Port B header. The pins can be seen switching using an oscilloscope connected directly to the chip, but not on the header.

Note: The clock speed selected in the Flowcode program (Chip -> Clock Speed menu) was 20MHz. Flowcode can not set the operating speed of the device, but uses this figure to perform several timer based calculations during compilation (delays, baud rates, pwm, etc.) This figure should always match the clock speed of the target device.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

sean wrote:The fuse settings I sent previously were to configure the chip to run from an external XTAL source - the one on the STK500 board.

The option to allow use of Port B 6/7 is to run from the internal calibrated RC oscillator. The fuses can select operation from the internal oscillator at 1, 2, 4 and 8 MHZ.

The first fuse value is 0xdf for all options. The second fuse setting is frequency dependent, 0xe1 = 1MHz, 0xe2 = 2MHz, 0xe3 = 4MHz, 0xe4 = 8MHZ.

Example fuse settings to run an Atmega8 from the internal oscillator at 8MHz:

0x0,0xdf
0x1,0xe4

Unfortunately, it would appear that the STK500 board does not track Port B pin 6/7 from the SCKT3200A2 socket to the Port B header. The pins can be seen switching using an oscilloscope connected directly to the chip, but not on the header.

Note: The clock speed selected in the Flowcode program (Chip -> Clock Speed menu) was 20MHz. Flowcode can not set the operating speed of the device, but uses this figure to perform several timer based calculations during compilation (delays, baud rates, pwm, etc.) This figure should always match the clock speed of the target device.
Of course. I just looked at the STK500 schematics. Here it showes that PB6 and 7 are only connected to the XTAL. I proberly should have checked it first - sorry.
Thank you for the fuse settings. Is there a complete overview of those somewhere?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

The data sheets for all the AVR devices can be downloaded from the Atmel website.

The fuse settings are generally in the Memory Programming section. The values sent from Flowcode are:

0x0,<high fuse bite>
0x1,<low fuse bite>
0x2,<extended fuse byte>

Not all fuse bytes are supported by every device type.

There are several fuse value calculators on the internet

http://www.engbedded.com/fusecalc/

Or google 'AVR fuse calculator'

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

sean wrote:The data sheets for all the AVR devices can be downloaded from the Atmel website.

The fuse settings are generally in the Memory Programming section. The values sent from Flowcode are:

0x0,<high fuse bite>
0x1,<low fuse bite>
0x2,<extended fuse byte>

Not all fuse bytes are supported by every device type.

There are several fuse value calculators on the internet

http://www.engbedded.com/fusecalc/

Or google 'AVR fuse calculator'
Brillant. Thank You! :)

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

TomasS wrote:Hi

I am a newbe using Flowcode and would like to use an STK500 as platform. But how do I setup Flowcode to use the STK500? Should I connect an AVRISP MKII to the ISP connector on the STK500 or should I use a USB to RS232 converter and connect to the DP9-connector?

I hope there is a helpful person in here, that can guide me a little, so I can continue using this great tool 8)

BR

Tomas
It has been a while since I used Flowcode on the STK500 - In the meantime I have upgraded to ver. 4 - But now I cannot do any downloading again :(
The RESET jumber is disconnected, but when I try to download the program I get the message:

"Launching the programmer...
C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\MX_bats\avrc.bat STK500 m32 atmega32 "C:\Users\tsk\Dropbox\TEKNIK~1\Flowcode\LEDtest.hex" "LEDtest.hex" 0 2 223 255 -1

C:\Users\tts\Dropbox\Flowcode>"C:\Program Files\Atmel\STK500\Stk500.exe" -cUSB -datmega32 -e -if"C:\Users\tts\Dropbox\Flowcode\LEDtest.hex" -pf -vf

STK500 v 1.20 (C) 2000-2002 Atmel Corp.

Detecting.. FAILED!
Error returned from [stk500]

Return code = 1"

Where do I go wrong this time?

BR
Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Using STK500 with Flowcode

Post by Sean »

You could try the AVRDUDE option in the programmer parameter string (instead of STK500) to see if the AVRISPmkII driver has been changed by the Flowcode update.

If you have AVR Studio installed, you can check if it is able to communicate with the AVRISPmkII. Or use Device Manager on your PC to display the driver that has been selected for the programmer (either Jungo (for STK500, or Libusb for AVRDUDE).

Either option will allow you to program an STK500 board using the AVRISPmkII. But if you also want to usethe programmer with AVR Studio, the driver will need to be Jungo. Other threads on this forum describe how to swap between the two usb drivers.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

Sean wrote:You could try the AVRDUDE option in the programmer parameter string (instead of STK500) to see if the AVRISPmkII driver has been changed by the Flowcode update.

If you have AVR Studio installed, you can check if it is able to communicate with the AVRISPmkII. Or use Device Manager on your PC to display the driver that has been selected for the programmer (either Jungo (for STK500, or Libusb for AVRDUDE).

Either option will allow you to program an STK500 board using the AVRISPmkII. But if you also want to usethe programmer with AVR Studio, the driver will need to be Jungo. Other threads on this forum describe how to swap between the two usb drivers.
Hi Sean

I cannot find AVRDude on my pc. Is it automaticly installed with FlowCode V4?
Jungo is available in the Device Manager with a WinDriver attach to it. I have installed AVR Studio - just to have the program, but I do not use AVR Studio for anything besides that.

BR

Tomas

User avatar
Steve
Matrix Staff
Posts: 3427
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Using STK500 with Flowcode

Post by Steve »

AVRdude should be in the Tools folder of Flowcode V4 for AVR.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time

Re: Using STK500 with Flowcode

Post by TomasS »

Steve wrote:AVRdude should be in the Tools folder of Flowcode V4 for AVR.
Thank You Steve - It did. I changed the avrc.bat to:

@SET STKPath="C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\AVRDUDEusb\avrdude.exe"


@REM Select programmer utility
@IF "%1" == "STK500" GOTO STKprog


@REM -------------- AVRDUDE programmer --------------

@SET Fuse1=
@SET Fuse2=
@SET Fuse3=


@REM %6 is the flag to send fuse data instead of the program
@IF "%6"=="1" GOTO Config


:progFlash
@SET AVRDUDEcmd="%~dp0..\AVRDUDEusb\avrdude.exe" -p %2 -P %DUDEPort% -c %Programmer% -U flash:w:%5
@SHIFT
@GOTO Send


:Config
@SET AVRDUDEcmd="%~dp0..\AVRDUDEusb\avrdude.exe" -p %2 -P %DUDEPort% -c %Programmer% -u

@REM %7 is the number of fuses present
@IF "%7"=="1" GOTO ConfigOneFuse


:ConfigThreeFuses
@IF NOT "%8"=="-1" SET Fuse1=-U hfuse:w:%8:m
@IF NOT "%9"=="-1" SET Fuse2=-U lfuse:w:%9:m
@SHIFT
@IF NOT "%9"=="-1" SET Fuse3=-U efuse:w:%9:m
@GOTO Send


:ConfigOneFuse
@IF NOT "%8"=="-1" SET Fuse1=-U fuse:w:%8:m
@SHIFT
@GOTO Send


:Send
@REM Now add any additional command line parameters here
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
@SHIFT
%AVRDUDEcmd% %Fuse1% %Fuse2% %Fuse3% %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@IF %ERRORLEVEL% NEQ 0 GOTO DUDEError
@GOTO End


:dUDEError
@ECHO.
@ECHO Error returned from [avrdude]
@EXIT 1


:STKprog
@REM -------------- STK500 programmer --------------

@SET STK500cmd=%STKPath% -c%STKPort% -d%3 -e -if%4 -pf -vf
%STK500cmd%

@IF %ERRORLEVEL% NEQ 0 GOTO STKError
@GOTO End

:STKError
@ECHO.
@ECHO Error returned from [stk500]
@EXIT 1

:End
@ECHO.
@ECHO Programming successful!
@EXIT 0[/b]


But it still returns with:

Launching the programmer...
C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\MX_bats\avrc.bat STK500 m32 atmega32 "C:\Users\tsk\Dropbox\TEKNIK~1\Flowcode\Blinklys.hex" "Blinklys.hex" 0 2 223 -1 -1

C:\Users\tsk\Dropbox\Teknikfag\Flowcode>"C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\AVRDUDEusb\avrdude.exe" -cUSB -datmega32 -e -if"C:\Users\tsk\Dropbox\TEKNIK~1\Flowcode\Blinklys.hex" -pf -vf

Error returned from [stk500]

Return code = 1

Flowcode was unable to transfer flow chart to the microprocessor. Check programs options and physical connections.

FINISHED


... after compilation and linking.

Do you know what can be wrong?

User avatar
Steve
Matrix Staff
Posts: 3427
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Using STK500 with Flowcode

Post by Steve »

It looks like AVRdude is returning an error code. You could try running the command directly from a command prompt:

Code: Select all

"C:\Program Files\Matrix Multimedia\Flowcode AVR V4\Tools\AVRDUDEusb\avrdude.exe" -cUSB -datmega32 -e -if"C:\Users\tsk\Dropbox\TEKNIK~1\Flowcode\Blinklys.hex" -pf -vf 
I'm hoping you'll receive a useful error message. If not, then you may need to get support from the AVRdude community. Personally, I have rarely used this particular programmer and so I'm not in a good position to help much.

Post Reply