--- In AVR-Chat@yahoogroups.com, "Ted Smith" <tedsmithau@y...> wrote: > > Hi, I'm probably the oldest living active programmer in Australia and > have decided to have a go at AVRmega16's before I die - hopefully > using Bascom basic. > I have done a lot with VB6 and assembly with the old 6502's 25 years > ago but can't find anywhere any concise info on how to structure the > AVR programs and integrating the various sub-routines, interrupts etc. > It all seems so disjointed and every article I have found so is > written by someone who assumes I know what they know. (Like Microsoft > help screens of the past) > Can anyone point me to a good step by step starting guide on how to > compose a simple program to say accept a few switch inputs and output > to a few leds while displaying information from the EEprom on an LCD > depending on what switch is pressed? > With the old 6502 I would have used interrupt routines for the > switches and had a loop polling the inputs and simply written to > output port addresses with an indexed address looking up data > depending on the switch number. > I can't seem to rationalise this to the AVR or is it done another way? > Thanks Ted Smith > Ted There are only a few interrupts on the Atmel chips - not like some processors that can have interrupts on all inputs. Nobody has tried to suggest how you go about writing a programme (but then that's a whole new ball game in it's self). If you haven't already got some hardware then I suggest (as John S did) that you get some strip board and a crystal and make something up for your self. These days I tend to use the spot board that Dick Smith sells and use wire wrap wire to solder between points. Put a 5v regulator on the board and then you can power it with anything (within reason!). I also have a number of 10 pin IDC headers on the board, each one of which is wired (pin for pin) to a port and then pin 9 is ground and 10 is +5v. That way I can make up small daughter boards to plug into the main board. The daughter boards can have LEDs, switches, RS232 driver, LCD connector, etc on them for flexibility. For programming the chip a simple way is to use a parrallel port (if you have one). There are lots of circuits out there (one in the Bascom Help Manual even) that can be used. I suggest you use one that has the 74LS244 in the circuit rather than the simple programmer . Look in the Help manual for ISP PROGRAMMER. To start you on the way programming try putting a set of LEDs on port B wired through a 2k2 resistor to ground and a set of switches on port A. Set up port A as input with pull ups and port B as outputs. Write a small loop programme that: a) input PINA ' gets switches b) output PORTB ' puts LEDS on/off c) wait d) goto back to a Note that to read a pin or a port you have to use PINx while output uses PORTx! I wish I had a dollar for every time I try and read using PORTx instead of PINx! There are several constructs for looping back. FOR, DO-LOOP, WHILE-WEND, GOTO, etc. All of which you will be familiar with. There are several contructs of WAIT as well or you can use a timer, etc. The important thing is that you cannot generally interrupt on a change of a switch wired onto a port pin. There are a couple of interrupt pins that can be used though. The start of you programme needs to a) declare all you variables, arrays, etc (see DIM inthe manual) b) decalre and constants (see CONST) c) set up your ports (see CONFIG) d) set up any peripherals/timers (see CONFIG) e) enable any interrups Look at the sample programmes to get the idea. Also the Bascom Forum ( at http://www.mcselec.com/) is a useful place to visit. HTH Alan
Message
Re: I cant get started
2005-12-21 by jenalcom
Attachments
- No local attachments were found for this message.