Attiny13 Software Uart Bascom
I did not find much information about how can you calculate the time using timer1 on Atiny 85. All tutorials are dealing with timer0, Timer 1 is a particular one is not compatible with others, It has precallers from 1/2-1/16384 Synchronous Clocking Mode.
Software UART The AT90S2313 and most other AVR controllers has a hardware UART on pins 2 and 3. Sometimes you have to use these pins for another purpose. Bascom has a software UART function that uses extra program space, but you may specify which pins to use for RxD and TxD. The pins to use are specified in the Open command.
The problem is that about any prescaler I chose lets say on internal clock 8Mhz with normal formula. (1/clock)*prescaler=Timer tick.I get totally different timing than one expected.I load the time on OCR1A and toggle some pins the time is much less. I cleared before TCCR1=0 so does not have other prescaler set. Can you give me a hint on what is going on?I did not find any info on how to calculate timing on timer 1.It seems different than normal timer0 I can manually trial and error tweak for the value I need but this is not professional. If you want accurate timing, say for sampling a serial UART input, then you are much better off using the hardware to reset the counter as there will be no lag. If you reset the counter inside your interrupt service routine then you are going to have to account for the drift introduced by running the code.
The ISR preamble takes about 42 CPU cycles to execute; there is overhead to execute the interrupt, disable global interrupts and to save registers. So in your example the counter reset is apx 43 CPU cycles after the compare match. So after the initial two toggles, the pin is being toggled every 93 (50 + 43) CPU clock cycles. Code lag on executing a timed action can be fine, e.g. Toggling the pin 45 CPU cycles after a compare match that triggers an interrupt every 100 cycles would still give you a pin that toggled every 100 cycles. However introducing code lag into the reset of your counter changes the actual timing.
Bascom and AVR, Using small AVR's 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. 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. 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: 'The ATTiny2313 is used. Confidence interval analysis cia software download. $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.