Go Down

Topic: TinyISP/attiny + CP2102 usb to uart bridge (Read 1 time) previous topic - next topic

hilukasz

May 05, 2013, 10:37 pm Last Edit: May 05, 2013, 11:48 pm by hilukasz Reason: 1
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.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

hiduino

Do you have sample code of what you are trying?

And any schematics or pictures?


hilukasz


Do you have sample code of what you are trying?

And any schematics or pictures?




Code: [Select]
#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.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

hiduino

#3
May 07, 2013, 03:31 am Last Edit: May 07, 2013, 03:53 am by hiduino Reason: 1
Don't use Knock_Bang.  Use the software serial that should be part of Tiny-core.

Code: [Select]

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


hilukasz


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

Code: [Select]

/*
  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 :/
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

hilukasz

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 :/
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Erni

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

Go Up