Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Newbie

Status
Not open for further replies.

cardkicker

New Member
I want to program the AT90S2313 to blink a light just something to get me started, i have the 2313 pdf complete and i dont understand much of it also i have avr studio and i can see the ports such as DDRB, PortB and PinB butt i just aint getting the ideal of how this works. I can right code such as...
.include "2313def.inc"
rjmp main

main:
ldi r16 ;I no r16 is a registor butt what is it for?i dont
out Portb,r16 ;understand
Please help if can??? :(
 
Let me take a jab at it, although I don't know any avr and just read the 2313 datasheet for the very first time. I remember AVRs have many working registers as opposed to PICs which only have one, so I assume R16 is one of them.

Now, LDI is supposed to have 2 operands, Rd,K and Rd <- K.
So I guess it's putting constant K into Rd.
So are you missing an operand here?

Next, the OUT command only accepts a value from a register. You can't throw it a constant and expect it to automatically put the value in a register, and then execute the OUT command. That is why we need to pass it a value via r16. Is this where you are unsure of?
 
Source Code

Hello

ldi (Load Imidiate) r16, 0b11111111 (or 0x1f[forhex])

That will load 8-bit into register 16. Notation of such commands is alway-> target, source

out PORTB, r16

Did you define DDRB fully as exit?

Do so in main:
ldi r16, 0b11111111
out DDRB, r16
for the counter
ldi r16, 0b00000000
ldi r17, 0b00000000
ldi r18, 0b00000001

But that wont get your LED blink'in. I suggest you wont even see it flash. The Micro will work with its Core speed. Estimated 10 or 24 Mhz

You will need to set a routine (a counter) and a bit rotation to see it blink.

mainloop:

wdr

echo:

inc r16
brne wait
inc r17
brne wait
rol r18
out PORTB, r18
wait:
rjmp mainloop
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top