Humboldt, CA
Offline
Full Member
Karma: 1
Posts: 220
Arduino BBB
|
 |
« Reply #45 on: June 13, 2011, 12:11:38 am » |
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
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #46 on: June 13, 2011, 12:50:06 am » |
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
Jr. Member
Karma: 0
Posts: 64
|
 |
« Reply #47 on: June 17, 2011, 05:17:11 am » |
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. /*
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
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #48 on: June 17, 2011, 01:16:07 pm » |
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! 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. Did I get all this correct? Looks like it.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 64
|
 |
« Reply #49 on: June 18, 2011, 10:25:38 am » |
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.
|
|
|
|
« Last Edit: June 18, 2011, 10:33:36 am by MGeo »
|
Logged
|
|
|
|
|
Deep south of Italy
Offline
Faraday Member
Karma: 6
Posts: 2955
The quieter you become, the more you can hear
|
 |
« Reply #50 on: June 18, 2011, 02:16:05 pm » |
what about to add the Attiny4313 support to Tiny core ? ( attiny2313 bigger brother ) are you planning to do it?
|
|
|
|
|
Logged
|
|
|
|
|
Scotland
Offline
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #51 on: June 18, 2011, 03:06:09 pm » |
I designed this to use 8 pin ATtinys , got a few so if anyone want them, they can have them cheap:
Drew
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #52 on: June 18, 2011, 11:18:59 pm » |
Works like a charm. Excellent! 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. 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. Now known as Tinyduino (is that taken?). Seems familiar but that's probably because of all the *duino names! So at this point I have I2C slave working With the library BroHogan published? I like the little board.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #53 on: June 18, 2011, 11:24:31 pm » |
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
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #54 on: June 18, 2011, 11:28:26 pm » |
I designed this to use 8 pin ATtinys , A very nice board. I like it. 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
Faraday Member
Karma: 6
Posts: 2955
The quieter you become, the more you can hear
|
 |
« Reply #55 on: June 18, 2011, 11:51:39 pm » |
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 
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #56 on: June 19, 2011, 12:46:32 am » |
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. after creating a board.txt entry for my tests, i've been able to compile the blink setch and it works Excellent!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 64
|
 |
« Reply #57 on: June 19, 2011, 04:11:55 am » |
With the library BroHogan published?
Yep, BHogan TinyWireS lib as documented above in Reply #28. Best Regards, George
|
|
|
|
|
Logged
|
|
|
|
|
Deep south of Italy
Offline
Faraday Member
Karma: 6
Posts: 2955
The quieter you become, the more you can hear
|
 |
« Reply #58 on: June 19, 2011, 11:04:44 am » |
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.pdfand it worked (beside the steps i said before, about winavr ecc..)
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #59 on: June 20, 2011, 02:44:10 am » |
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? 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
|
|
|
|
|
|