Go Down

Topic: Arduino Tiny (Read 66638 times) previous topic - next topic

Bobnova

Ok so I've found timer1 in the datasheet and have starting digging in.  This looks very promising!
The only question I have at the moment is, how can I change just some of the bits in a control register byte?
For instance, say I want to (in the middle of a sketch) change the last four bits of TCCR1, and not the first four bits, how do I do this?

Armed with that knowledge, I think this project of mine (including changing PWM speed within the sketch) is not only doable, but fairly easy.

Coding Badly


What I typically do so the intent is crystal clear...

[font=Courier New]TCCR1 =
 ( TCCR1 & ( (1 << CTC1) | (1 << PWM1A) | (1 << COM1A1) | (1 << COM1A0) ) )  // Strip the first four bits
 |  // Merge with the next four bits
 ( (0 << CS13) | (0 << CS12) | (1 << CS11) | (0 << CS10) );  // Last four bits
[/font]

MGeo

#47
Jun 17, 2011, 12:17 pm Last Edit: Jun 17, 2011, 12:27 pm by MGeo Reason: 1
Coding Badly,

Slowly working on TinyDebugSerial.

A clarification please.  From http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285218245/25#25
"Serial transmit pin is PB3 / pin 3.  Basically, the transmit pin is the first I/O pin in the upper-left corner. "  I soldered up pin 3 in my TinyDuino and tried it but no joy.  I assigned pin 2 to as output to power a diagnostic LED as well.

Checking the data sheet, PB3 is pin 2 and is the first I/O pin in the upper left corner (not counting /RESET, which can be used for I/O if you want it bad enough?).  This means the pin 2 LED output assignment was stomping on TinyDebugSerial.

So... I am switching to pin 2, and modifed the test sketch to what is attached below.  Did I get all this correct?  Want to clarify so others can follow.

Code: [Select]
/*

ATMEL ATTINY45/ARDUINO:
                 +--\/--+
Ain0 (D5) PB5  1 |      | 8  VCC
Ain3 (D3) PB3  2 |      | 7  PB2 (D2) Ain1 INT0
Ain2 (D4) PB4  3 |      | 6  PB1 (D1) pwm1
          GND  4 |      | 5  PB0 (D0) pwm0
                 +------+

*/

#define LED_PIN           4                     // ATtiny Pin 3 (D4)

void setup(){
 pinMode(LED_PIN,OUTPUT);                      // for general DEBUG use
 LED_Blink(LED_PIN,2);                         // show it's alive
 Serial.begin(9600);
}

void loop() {
 int test = 0x31;
 Serial.println( F("This string only consumes Flash.") );
 Serial.print(test);
}

// LED blinker for status
void LED_Blink(byte pin, byte times){
 for (byte i=0; i< times; i++){
   digitalWrite(pin,LOW);
   delay (1000);
   digitalWrite(pin,HIGH);
   delay (1000);
 }
}


Thanks again for all the help,
George

Coding Badly


Argh!  I hate that the Arduino folks called them "pins".  Why not use the Latin word instead (acus)?  Then Ancient Romans would be the only ones confused!

Quote
Serial transmit pin is PB3 / Arduino pin 3 / DIP package pin 2.  Basically, the transmit pin is the first I/O pin in the upper-left corner.


Quote
Did I get all this correct?


Looks like it.

MGeo

#49
Jun 18, 2011, 05:25 pm Last Edit: Jun 18, 2011, 05:33 pm by MGeo Reason: 1
Works like a charm.  Not having to close the terminal window for each download is much better, and I can use any terminal or serial application I want.

I put a socketed ATTiny85, decouple cap and ICP connector on a proto-board so I can plug it into my breadboard.  Now known as Tinyduino (is that taken?).  So at this point I have I2C slave working and now have a nice serial dubug port thanks to excellent Arduino Tiny core and Pololu USB.  Time for next phase of project.

BrainBooster

what about to add the Attiny4313 support to Tiny core ? ( attiny2313 bigger brother )
are you planning to do it?

spycatcher2k

I designed this to use 8 pin ATtinys , got a few so if anyone want them, they can have them cheap:




Drew
Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Coding Badly

Quote
Works like a charm.  


Excellent!

Quote
Not having to close the terminal window for each download is much better, and I can use any terminal or serial application I want.


That alone makes the Pololu Programmer worth the money.

Quote
I put a socketed ATTiny85, decouple cap and ICP connector on a proto-board so I can plug it into my breadboard.


Nice.  

Two things I've found that work well...

1. Teensy (with pins) + (modified) Arduino ISP + small bread board + ATtiny85.  It's nice simple / single project prototyping tool.

2. Male pins on the the Pololu Programmer (+5V, GND, RX, TX, A, B).  It can then be inserted onto the edge of a breadboard.

Quote
Now known as Tinyduino (is that taken?).  


Seems familiar but that's probably because of all the *duino names!

Quote
So at this point I have I2C slave working


With the library BroHogan published?

I like the little board.

Coding Badly

#53
Jun 19, 2011, 06:24 am Last Edit: Jun 19, 2011, 06:28 am by Coding Badly Reason: 1
Quote
what about to add the Attiny4313 support to Tiny core ? ( attiny2313 bigger brother ) are you planning to do it?


A look at the migrating document...

http://www.atmel.com/dyn/resources/prod_documents/doc8283.pdf

...reveals there really is no significant difference between the two.

The Tiny Core has support for the ATtiny2313.

Have you tried programming the 4313 using one of the 2313 selections?

Coding Badly

Quote
I designed this to use 8 pin ATtinys ,


A very nice board.  I like it.

Quote
got a few so if anyone want them, they can have them cheap:


I've been trying to think of a reason to get one but I just can't think of how one would fit in my menagerie.

BrainBooster

I changed a little the original core files to add support for te 4313 (on the 2313 base), and then i replaced the winavr in the arduino folder with the new one. (the old one says:4313 supported only for assebly)
after creating a board.txt entry for my tests, i've been able to compile the blink setch and it works :)
now i have to do further tests but it looks promising :P

Coding Badly

Quote
I changed a little the original core files to add support for te 4313 (on the 2313 base)


If you don't mind my asking, what did you change?  I'd like to make the changes to Tiny Core.

Quote
after creating a board.txt entry for my tests, i've been able to compile the blink setch and it works


Excellent!

MGeo


With the library BroHogan published?


Yep, BHogan TinyWireS lib as documented above in Reply #28.

Best Regards,
George

BrainBooster

just to add a basic support i've changed the 2313 ifdefinitions like this:
if defined( __AVR_ATtiny2313__ ) || defined( __AVR_ATtiny4313__ )
'cause it is basically the same soup :)
almost the same...  http://www.atmel.com/dyn/resources/prod_documents/doc8283.pdf
and it worked (beside the steps i said before, about winavr ecc..)

Coding Badly

Quote
Yep, BHogan TinyWireS lib as documented above in Reply #28.


Thanks.

Have you had any problems with it?  Made any changes?  Thought of any enhancements you'd like added?

Quote
just to add a basic support i've changed the 2313 ifdefinitions like this:
if defined( __AVR_ATtiny2313__ ) || defined( __AVR_ATtiny4313__ )


Got it.  Thanks.

I added a request to the issue list...
http://code.google.com/p/arduino-tiny/issues/detail?id=3

Go Up