Bascom and AVR, Using small AVR's


It does not get much smaller. Take a 'tiny' ATTiny13 SMD eight-pin chip. It has 1k program memory, 64 bytes SRAM, 64 bytes EEPROM. You can use five I/O pins in Bascom. It is tiny, but can run as fast as 20MHz!
And it can still be programmed as any other AVR with only the SCK, MISO, MOSI and RESET pins.


(I have used an SMD Led and current-limiting resistor soldered directly to the chip)

Make sure you read the ATTiny13 datasheet.

Try this schematic:



Start TWinAvr, and click on Config. These are the fuse settings of a blank ATTiny13:

The ATTiny13 starts default with an internal RC oscillator at 9.6 MHz. This is prescaled by 8, giving a clock speed of app. 1.2MHz. You can unprogram the CKDIV8 fuse, setting the clock speed to the full 9.6MHz.
The ATTiny13 can run as fast as 20MHz, but then you need to set the CKSEL fuses to "00" and an external clock connected to Pin 2 (PB2/CLKI)
Try this program to get a flashing Led:
ledflasher.bas
'The ATTiny2313 is used.
$regfile = "ATtiny13.dat"
$crystal = 1200000

Config Portb = Output

Do
  Portb = 255
  Waitms 50
  Portb = 0
  Waitms 50
Loop

End
But the ATTiny can do more. It has a 10-bit ADC on pins 1, 2, 3 and 7. An example program to read one ADC channel:
readadc.bas
'The ATTiny13 is used.
$regfile = "ATtiny13.dat"
$crystal = 1200000

Config Portb.2 = Output
Led Alias Portb.2
Config Adc = Single , Prescaler = Auto , Reference = Internal

Dim Adcin As Word

Open "comb.1:9600,8,n,1" For Output As #1
Open "comb.0:9600,8,n,1" For Input As #2
Start Adc

Do
  Set Led
  Waitms 500

  'get adc reading on channel 3 (pin 2 on attiny13)
  Adcin = Getadc(3)
  Print #1 , "adc ch#3: " ; Adcin
  Reset Led
  Waitms 500
Loop

End
A software UART is used to send the ADC readings to the PC. You may use Bascom's terminal program to display the results (Tools/Terminal emulator; then in the terminal emulator, do Terminal/Settings and set port to Com1 and speed to 9600 baud)
Although in the program comb.0 is opened as input, it is not used in the program, but you could try sending commands to the ATTiny13.
This program takes up slightly more than 50% of the ATTiny13 flash memory. So, for 'tiny' tasks it fits the bill nicely!

TOC