From: Self To: bascom@grote.net Subject: My very first AVR... Send reply to: adean@adx.co.nz Date sent: Mon, 15 May 2000 19:33:58 I thought I'd tell the story of my first AVR experience, just because it went so well! Background: I've never used an AVR micro before, I've been keeping my distance because of yet another learning curve. But the existence of BASCOM-AVR made me think again, plus the AVRs are cheap and available, and include A/D and PWM unlike Atmel's 8051range (which are also cheap and available). So I bought some samples of AT90S4433. I have read some AVR datasheets while doing a feasibility study, but otherwise that's about it. So I tried a little experiment - how long would it take to get one up and running from scratch, and what head-bashing-against-brick-wall 'challenges' would I encounter along the way? Here's the results: 1 Sorting out ISP Look in datasheet. 4 lines + GND. Since I'm using the 4433 with onboard reset, I can connect reset to 5V through a resistor (no cap needed). Decided to make the Sample Electronics simple cable programmer as in the BASCOM-AVR helpfile (it's just wire) rather than use my AVR dev kit which is in use for 8051 development. Spent some time making a proper programming cable complete with shielded wire, 100E resistors in datalines just in case, keyed connector with what I think is the right pinout (copied from AVR dev kit) and strain relief. This took 1hr 24 mins. 2 Made some hardware on veroboard. Printed pinout from datasheet. Need to connect analogue supplies and reference (used filter as per datasheet), 4MHz resonator, 5V reg and caps, ISP header, and a LED to PD1 so I could see it do something. This took 49 minutes. 3 Software Wrote a simple program in BASCOM-AVR to flash the led, had to refer to the helpfile to configure the funny AVR ports. Unforunately the first compile failed due to me not selecting the correct processor type. Second time successful and no errors (no need to change code). Applied power to the board, made sure I had the correct programmer type selected (learning!), and programmed first time no problems. Then I looked down and it was working! (LED flashing 1 second on, 1 second off). This took 13 minutes. '14-5-00 'ADX Electronics 'First AVR program - flash LED on PD1 $crystal = 4000000 Config Portd = Output Main: Portd.1 = 0 'led on Wait 1 Portd.1 = 1 'led off Wait 1 Goto Main So - 2 hrs 27 all up, and apart from having the wrong processor selected initially, EVERYTHING worked very first time. It's neat when that happens! With some chips / development systems you can bash your head agaist brick walls for hours (or days) sorting out trivial problems... Also, having used bascom-LT and 8051 I would be comfortable writing something more complex for AVR even if I can't use assembly right away. Plus as a H/W engineer, it's good to see that the S/W is still the simplest part :-) Still, I'll be sticking to 8051s and PICs for the mean time - it's just good to have such an encouraging start into a new micro! Antony.