Pages: 1 2 3 [4] 5 6 ... 22   Go Down
Author Topic: Arduino Tiny  (Read 58155 times)
0 Members and 1 Guest are viewing this topic.
Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

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
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*

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
« Last Edit: June 17, 2011, 05:27:00 am by MGeo » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* BlintSerialTest.JPG (218.3 KB, 1632x1224 - viewed 32 times.)

* TinyDuino 001.jpg (223.67 KB, 1632x1224 - viewed 26 times.)

* TinyDuino 002.jpg (237.47 KB, 1632x1224 - viewed 35 times.)

* TinyDuino 004.jpg (161.1 KB, 1632x1224 - viewed 36 times.)
« Last Edit: June 18, 2011, 10:33:36 am by MGeo » Logged

Deep south of Italy
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2955
The quieter you become, the more you can hear
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Scotland
Offline Offline
Edison Member
*
Karma: 24
Posts: 1246
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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




Drew


* robo.jpg (149.89 KB, 389x519 - viewed 44 times.)
Logged

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

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: June 18, 2011, 11:28:46 pm by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Deep south of Italy
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2955
The quieter you become, the more you can hear
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
now i have to do further tests but it looks promising smiley-razz
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With the library BroHogan published?

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

Best Regards,
George
Logged

Deep south of Italy
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2955
The quieter you become, the more you can hear
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
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..)
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12782
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 2 3 [4] 5 6 ... 22   Go Up
Jump to: