kkazakos2003 wrote:
> Hello dear friends,
>
> I am currently new in th euse of STK500 for ISP programming.
> I am using an ATMEGA162.
>
> The little thing that I am trying to do is to light a led in the STK500.
>
> My code is like this:
> --------------------------------------------------
> .include "m162def.inc"
>
> .org 0x000
> rjmp RESET ;external pin, power-on and watchdog reset
>
> .def temp1 = r16
> .def temp2 = r17
>
> ;--Main source code
>
> RESET:
> ldi temp2,0xff
> out DDRB,temp2 ldi temp1,0x01
> out PORTB,temp1
>
> -----------------------------------------------
>
> I know it is quite simple, but i want to begin from the simple things
> first..
>
> The problem that I have is that it simply does not work in the STK500.
> I mean, when I used an ATMEGA161 it worked perfectly.
>
> Right now with th euse of the ATMEGA162 it does NOT work.
> ANd i cannot understand why..
>
> Please help me..
>
> thanks
Take the code from the stk help file writen for 8515
all you need to do is change the chip definition.
This code works for all the chips I've ever tryed it with.
Don't have a 162 to test with.
;***** STK500 LEDS and SWITCH demonstration
.include "m162def.inc"
.def Temp =r16 ; Temporary register
.def Delay =r17 ; Delay variable 1
.def Delay2 =r18 ; Delay variable 2
;***** Initialization
RESET:
ser Temp
out DDRB,Temp ; Set PORTB to output
;**** Test input/output
LOOP:
out PORTB,temp ; Update LEDS
sbis PIND,0x00 ; If (Port D, pin0 == 0)
inc Temp ; then count LEDS one down
sbis PIND,0x01 ; If (Port D, pin1 == 0)
dec Temp ; then count LEDS one up
sbis PIND,0x02 ; If (Port D, pin2 == 0)
ror Temp ; then rotate LEDS one right
sbis PIND,0x03 ; If (Port D, pin3 == 0)
rol Temp ; then rotate LEDS one left
sbis PIND,0x04 ; If (Port D, pin4 == 0)
com Temp ; then invert all LEDS
sbis PIND,0x05 ; If (Port D, pin5 == 0)
neg Temp ; then invert all LEDS and add 1
sbis PIND,0x06 ; If (Port D, pin6 == 0)
swap Temp ; then swap nibbles of LEDS
;**** Now wait a while to make LED changes visible.
DLY:
dec Delay
brne DLY
dec Delay2
brne DLY
rjmp LOOP ; Repeat loop forever

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )