Go Down

Topic: Problem with the ATTiny25 and Spence Konde core (Read 881 times) previous topic - next topic

pogcarr

OK, I am experiencing a problem that is, no doubt, simply do to my own ignorance.  I am pretty experienced with Arduinos but this is my first foray into ATTiny-land.  I have a sketch that runs fine on a Leonardo, but has a different output if run on the ATTiny.
Code: [Select]
int raw_adc = 128;
void setup() {
Serial.begin(9600);
//  pinMode(3, INPUT);
}

void loop() {
//  raw_adc = analogRead(3);
  Serial.print(raw_adc);        //This line works on an Arduino, but on the ATTiny25 prints a bunch of 8's and spaces!
//  Serial.print("Hello World");     //this line works fine 
  Serial.print(",");
  delay(25);
}


The purpose of the code is to read a voltage and send the value via serial port.  I have commented out the analogRead parts to troubleshoot.  When run on the Leonardo it outputs 128,128,128,128,128... as expected.  On the ATTiny I get a bunch of 8's and blanks!  It would seem that there is something different about how Serial is handled in Spence Konde's core but I just can't figure it out.

Any help is much appreciated!

DrAzzy

#1
Dec 07, 2017, 07:39 am Last Edit: Dec 07, 2017, 07:43 am by DrAzzy
Mysterious. I will investigate.

"Serial" on a tiny x5 with my core (well, actually any serial implementation for tiny x5) is a software implementation, and my cores use a special version that uses the analog comparator interrupt instead of a PCINT to improve library compatibility.

ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

pogcarr

DrAzzy, sorry didn't mean to cross post.  Just wanted to see if anyone here had experienced like problems or could point out some obvious mistake on my part! :-)

DrAzzy

#3
Jan 14, 2018, 08:28 am Last Edit: Jan 14, 2018, 08:30 am by DrAzzy
AAHA! Here's that issue I made the board up to test a while back... I knew it was somewhere but wasn't able to locate it when I had a chance to test the issue.

This is why issues should always be in github... otherwise it gets lost.

Issue created to track this bug report. https://github.com/SpenceKonde/ATTinyCore/issues/186
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

DrAzzy

#4
Jan 18, 2018, 05:32 am Last Edit: Jan 18, 2018, 05:32 am by DrAzzy
Cannot reproduce, code above works fine on my ATTiny85, and there are no relevant differences between Tiny85 and Tiny45 here.

I suspect the issue is down to the factory calibration of the internal 8mhz (or what passes for it) - it is not guaranteed to be accurate enough for UART communication. On most individual chips it is, at normal voltages and at room temperature, but this isn't guaranteed. You can user-calibrate it (sorry, no resources available to help - this is on my list but haven't had time), but that's a pain in the ass. This is why I try to always use a crystal when I'm relying on UART working (though at 3.3v the tiny841, 1634R and 828R have the oscillator calibrated precisely enough for that.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up