Pages: [1]   Go Down
Author Topic: TinyISP/attiny + CP2102 usb to uart bridge  (Read 1318 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to send data to my attiny via UART. Not sure if I am missing something. I am using the PB1(MISO) and PB0 (MOSI) pins but no luck. I've tried the CP2102 with arduino and it works well, but having some issues with attiny.

Reason I need to send data is because it uses a command to start the monitor, and I can't start it unless I am able to send a "!" to it.

edit: just to be clear I can read the serial data from arduino (using knockbang), its getting it to send the '!" command to initialize reading from the CP2102 that is giving me issues.
« Last Edit: May 05, 2013, 04:48:29 pm by hilukasz » Logged

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 30
Posts: 629
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have sample code of what you are trying?

And any schematics or pictures?

Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have sample code of what you are trying?

And any schematics or pictures?



Code:
#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>
 
#ifdef KNOCK_BANG
#define Serial Debug
#endif
void setup() {
    Serial.begin( 9600 );
}
 
void loop() {
    delay(1000);
    Serial.println("Can it be true?! An attiny serial monitor indeed!"); // debug output
}

thats the sketch. and as for how I am connecting it is simply gnd to gnd 3.3v to vcc on attiny and then that MISO and MOSI connections on the attiny from the uart bridge, its really simple connection. I can get it to work with arduino but not this core because I need to be able to send that "!" to initiate the serial monitor.
Logged

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Wahiawa, Hawaii
Offline Offline
God Member
*****
Karma: 30
Posts: 629
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't use Knock_Bang.  Use the software serial that should be part of Tiny-core.

Code:
/*
  TinySerial
  Echo back Serial data.
 
 */

#include <SoftwareSerial.h>

// Setup serial Rx to pin PB0(D0) and Tx to pin PB1(D1)
SoftwareSerial mySerial(0,1);
int data = 0;

void setup() {               
  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available()) {
    data = mySerial.read();
    mySerial.write(data);
  }
}

Note: There are some limitations with software serial Rx receiving.  Although you can use 9600 baud, it won't support back-to-back characters.  So as long as you send each data character spaced out with some delay between them then you should be fine.  Also for 9600 baud you need to be running at least the 8MHz internal clocking on the ATtiny.

« Last Edit: May 06, 2013, 08:53:55 pm by hiduino » Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't use Knock_Bang.  Use the software serial that should be part of Tiny-core.

Code:
/*
  TinySerial
  Echo back Serial data.
 
 */

#include <SoftwareSerial.h>

// Setup serial Rx to pin PB0(D0) and Tx to pin PB1(D1)
SoftwareSerial mySerial(0,1);
int data = 0;

void setup() {               
  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available()) {
    data = mySerial.read();
    mySerial.write(data);
  }
}

Note: There are some limitations with software serial Rx receiving.  Although you can use 9600 baud, it won't support back-to-back characters.  So as long as you send each data character spaced out with some delay between them then you should be fine.  Also for 9600 baud you need to be running at least the 8MHz internal clocking on the ATtiny.



I can get my example to work, but yours seems to not work :/
Logged

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

actually code on this page seemed to work. http://wiki.sgmk-ssam.ch/index.php/SGMKtiny only difference is the baud rate, no idea why it work work and not yours otherwise :/
Logged

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1084
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To obtain a more reliable connection when using SoftwareSerial, you can
tune the internal oscillator:

http://forum.arduino.cc/index.php/topic,8553.0.html
Logged

Pages: [1]   Go Up
Jump to: