Show Posts
Pages: [1] 2 3 ... 40
1  Development / Other Software Development / Re: USI Serial, Hardware Serial for ATtiny on: September 28, 2013, 04:05:02 pm
From a quick look at the usi-uart-config.h I can't immediately see how to know if it would work on an Attiny45 at 1MHz?


Right, this is a complicated calculation, you can't see it immediately. So if you really want to know, you need to go through the #define preprocessor calculations by hand.

If the final calculated timer value is too low, then the ISR may not execute fast enough

If the timer value is large enough, then the second problem is accuracy. There are two values, one for half of a bit and one for one full bit width. You need to compare what the full bit width should be with the one calculated by the preprocessor.

To be fair, 1 MHz is not exactly a UART friendly clock speed to begin with, and it is already super slow. On an ATmega (I know we are using ATtiny), you can probably achieve 2400, 4800, and 9600 baud (I'm looking at the table inside the datasheet for an ATmega328P, 9600 requires the 2X speed bit to be set as well). I'm not exactly hopeful.

Going through step by step for 9600 baud (I'm kind of interested myself so I'll go through it with you)

#define TIMERn_SEED               (256 - ( (SYSTEM_CLOCK / BAUDRATE) / TIMER_PRESCALER ))

#define TIMERn_SEED               (256 - ( (1000000/ 9600) / 1))

This calculates to 152



#define TIMER_PRESCALER           1

#if ( (( (1000000 / 9600) / 1) * 3/2) > (256 - 0x11) )

#if ((156) > (239))

This is false, so we go to the #else

    #define INITIAL_TIMERn_SEED       ( 256 - (( (SYSTEM_CLOCK / BAUDRATE) / TIMER_PRESCALER ) * 3/2) )

   #define INITIAL_TIMERn_SEED       ( 256 - (( (1000000/ 9600) / 1) * 3/2) )
    #define USI_COUNTER_SEED_RECEIVE  (16 - 8)

INITIAL_TIMERn_SEED calculates to 100

Both of these should be large enough for the ISR to execute completely before the next ISR

Now to calculate the accuracy

9600 baud means a bit width of 104.17us, while TIMERn_SEED is 152 which is 152us, which is way too bad.

sidenote: how do I know my calculations match what the compiler is actually doing? I'm using
#define SYSTEM_CLOCK 1000000UL
#define BAUDRATE 9600
#define DATA_BITS 8
#define TIMERn_SEED               (256 - ( (SYSTEM_CLOCK / BAUDRATE) / TIMER_PRESCALER ))
    #define INITIAL_TIMERn_SEED       ( 256 - (( (SYSTEM_CLOCK / BAUDRATE) / TIMER_PRESCALER ) * 1/2) )
    #define INITIAL_TIMERn_SEED       ( 256 - (( (SYSTEM_CLOCK / BAUDRATE) / TIMER_PRESCALER ) * 3/2) )

int main(void)
    return 0;
2  Development / Other Software Development / USI Serial, Hardware Serial for ATtiny on: September 27, 2013, 03:03:40 pm
Download from my github:

UsiSerial is a simple wrapper around the code from AVR307 so that Arduino can use USI to implement a hardware serial port

The USI class works almost exactly like HardwareSerial
So you can use print and println and other functions like that

PORTB0 is DI, thus it is RX
PORTB1 is DO, thus it is TX
default baud rate is 19200, which can only be changed in USI_UART_config.h
only some baud rates will work, depending on CPU frequency
buffers are small to save memory, since this library is designed for ATtiny
testing was done using a 16 MHz Trinket

I don't know if this has been done before but I needed it and wrote it just a few minutes ago
3  Using Arduino / Microcontrollers / Re: How to program using USBASP and keep bootloader on: October 12, 2012, 11:23:39 pm
how to program using usbasp and still keep bootloader.
You can't, BTW.

(well, if you're using something outside of Arduino, you can merge the .hex files for the bootloader and your application.  Or you can set things up so that you burn the bootloader and then burn the app, or vis-versa, but overwriting an existing application always involves an "Erase all" step that will wipe out the bootloader.)

also just to follow up on this comment, if you do decide to merge the two hex files together, the programming process will take very long and get annoying.
4  Using Arduino / Networking, Protocols, and Devices / Re: Emulate USB device on: October 09, 2012, 07:10:04 pm
LUFA features both AudioInput and AudioOutput demonstrations, this is EXACTLY what you are looking for, modify the makefile for the ATmega16U2 and you should be good to go
5  Using Arduino / Microcontrollers / Re: avrdude hfuse verification mismatch on: October 06, 2012, 11:55:14 pm
maybe the effects of LFUSE needs some time to take effect, maybe the reset pin is not toggled between LFUSE and HFUSE operations

separate runs is a good idea, use a bash/batch script or makefile if you must automate it
6  Using Arduino / Microcontrollers / Re: Made My Own Arduino Board - ATMEGA32U4 - Bootloader Questions on: September 26, 2012, 01:31:58 am
a .hex file is in Intel Hex format, it's ASCII, human readable, not binary. You need two ASCII characters to represent every actual byte, plus there's some overhead in the Intel Hex format to indicate address and checksums. So it's file size does not indicate the true size of memory you need.

also keep in mind, your microcontroller has 32K total, the bootloader can occupy up to 4K, thus you have 28K remaining for application. So your reasoning is wrong in your original post.
7  Using Arduino / Project Guidance / Re: wifi jammer on: September 23, 2012, 10:06:42 pm
Is it really illegal to jam the 2.4 GHz band? I thought it was one of the bands that was "free for all", unlike cell phone bands.
8  Using Arduino / Networking, Protocols, and Devices / Re: Is there a 'Software SPI'? on: September 23, 2012, 08:18:14 pm
you are talking about bit banging SPI

shiftOut() is bit banging, pretty much exactly what you are looking for, see official Arduino reference for details

but please consider that SPI is designed to be used for multiple devices, so you shouldn't need to have a separate SPI bus for separate devices, unless you absolutely need parallel data transfer rates
9  Using Arduino / Programming Questions / Re: ADC problem on: September 20, 2012, 10:28:05 pm
try bit-shifting your sensorValue by 2 to the right instead of using map
10  Topics / Home Automation and Networked Objects / Re: A little lost... on: September 16, 2012, 12:37:00 am
Think about what is actually happening when somebody visits a web page

A TCP connection is made (over port 80 for websites, MOST of the time), you'll have to setup the Ethernet shield to open up port 80 and listen for this connection

a HTTP "GET" request is sent from the browser, specifying the page that they are looking for (there are other headers, like user agent, but we don't care for now)

your Arduino needs to catch this request, parse it, figure out which file is being requested

your Arduino needs to read the file from the SD card, at this point, you MUST know the file size in order to generate a proper content length for the next step

send the HTTP response header back, this usually includes the status code (404 for page not found, 200 for success, 500 for internal server error, etc), the data type is an important field, and so is content length

send the data from the SD card after content length is sent, I suggest doing it in 512 byte chunks (caching it in RAM from the SD card before sending it from RAM to Ethernet shield) because that's the size of any single read operation of a SD card, and it's also the sector size, most SD/FAT libraries use 512 bytes. To answer your question, the two devices cannot work simultaneously.

You can try playing with "developer tools" of your web browser, if it supports viewing HTTP headers. Or use a tool called Fiddler2.

Or you can find a library that does all this for you. But if you have POST requests, or any query strings in the GET request, you'll need to learn how to handle them manually. Cookies, user agent, error codes, these things all require you to understand HTTP
11  Community / Products and Services / Re: Great PCB House for Prototyping on: September 14, 2012, 12:58:20 am
I'm usually a fan of SeeedStudio but recently I've seen some comparisons between these three services (SeeedStudio, iTeadStudio, OSH Park), and OSH Park seems to have much better quality.

Read about the comparison here:

My next project might actually use 6 mil trace and spacing and 13 mil drills, I might need to use OSH Park to guarantee that the PCB actually works.
12  Development / Other Hardware Development / Re: Leonardo USB Vendor/Product ID on: September 12, 2012, 05:28:59 pm
Frank, have you tested the most minimal version (FT230XS) using the RTS instead of the DTR to perform a reset on Arduino?
Didn't managed to grab the FT230XS before it they pull them out of the stock.

Sorry, the boards I have used them on do not use flow control at all
13  Development / Other Hardware Development / Re: Leonardo USB Vendor/Product ID on: September 11, 2012, 11:11:55 pm
I've already used several in my projects, I guess they ran out, just wait for restock I guess, Digikey says expect them to restock 3rd of November 2012
14  Topics / Product Design / Re: Eagle file review please on: September 05, 2012, 06:47:27 pm
also BatchPCB's server will also run your design through a DRC robot, and email you back the results with the violations highlighted, you don't have to order the PCBs from them but you can take advantage of this bot. It sometimes catches things that the EAGLE DRC check misses.
15  Topics / Product Design / Re: Eagle file review please on: September 04, 2012, 11:29:00 pm
Hard to evaluate without a schematic.

How'd you get those colors in Eagle?

click the layers button, then just double click on the colour of the layer you want to change, a new dialog will show up and let you choose a colour
Pages: [1] 2 3 ... 40