Arduino Forum

Using Arduino => Microcontrollers => Topic started by: secretreeve on Nov 16, 2019, 01:04 pm

Title: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 01:04 pm
hi guys, i need help in selecting an attiny chip as i dont understand certain properties.

i am attempting to use the morse library but due to the requirement of hardware multipler? (see below quoted text) i need to find a chip that can handle the library from the attiny selection.

the mega chips such as the 328 is far too big and over powered for this project.

Quote
You'll want to look closer at ATtiny compatibility. I've never used one but here's a Stack Overflow article that seems helpful.
https://electronics.stackexchange.com/questions/80292/what-cant-the-attiny-do-that-the-arduino-can
It does mention that ATtiny doesn't have a full hardware-multiply implementation for factors other than 2. I notice in this "morse.cpp" that at least one function calls on floating-point multiply in MorseSender::setWPM(). Might be more spots; that's the first one I noticed.
Good luck, Barry
ive attatched the morse library as im actually not 100% sure thats the problem, perhaps someone more advanced will know.
Title: Re: attiny selection hardware multiplier
Post by: Smajdalf on Nov 16, 2019, 04:52 pm
In general you don't need a HW multiplier. It "only" makes multiplying faster with less code. I doubt you need the speed. Try it, the compiler should use the right SW routines for the multiply - you don't need to do anything about it (just specify what chip you intend to use which you need to do in either case).
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 04:57 pm
Except the attiny45 for example can't handle the Morse library apparently due to the multiplier. The compiler does nothing to compensate for anything
Title: Re: attiny selection hardware multiplier
Post by: Smajdalf on Nov 16, 2019, 05:12 pm
You are doing something wrong. What compiler do you use, what settings a what error do you get?
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 05:21 pm
I'm not doing anything wrong. I'm using the arduino software. It works fine on the mega328 but isn't compatible with the attiny45. It's not a problem with code, it's not a problem with circuitry. It's a chip compatibility issue.  Which is why I'm asking for recommendations of one that is compatible.

Well it is a code problem in that the library and chip isn't compatible so need a small chip that is.
Title: Re: attiny selection hardware multiplier
Post by: Smajdalf on Nov 16, 2019, 05:58 pm
Clearly you are doing something wrong. If there is a compatibility issue it is not due to the multiplier but due to another peripherals of the chip - maybe timers? If Arduino thinks it is compiling for Arduino Uno (ATMega328p) it will fail for any other chip. I am using Atmel Studio for programming of standalone chips so I don't know how to configure Arduino IDE but you must start with this.
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 06:01 pm
Okay I'm frustrated because I am not doing ANYTHING wrong. Everything is fine, it works on the arduino perfectly but not a 45. Despite the code writing successfully to the chip as verified by other code aspects working fine.

The Morse library DOES NOT work on the 45 so back to my original request for someone to look at the library and see what's going on with compatibility or recommend a chip that's small it WILL work with.

Please stop assuming I am doing something wrong as I'm perfectly capable to loading the program successfully and have been through this on other threads relating to it
Title: Re: attiny selection hardware multiplier
Post by: Smajdalf on Nov 16, 2019, 06:42 pm
If you are not doing ANYTHING work it is great - your project surely works. If it does not work something must be wrong. You do very little to help to find what is wrong. Missing HW multiplier is almost sure not the reason why it does not work. But since you don't say what is wrong I am not going to guess. Are you able to upload other code to ATTiny45? Are you unable to compile this particular code? Or you can compile it but it does not work? What it does and what it should do?
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 06:58 pm
If you are not doing ANYTHING work it is great - your project surely works. If it does not work something must be wrong. You do very little to help to find what is wrong. Missing HW multiplier is almost sure not the reason why it does not work. But since you don't say what is wrong I am not going to guess. Are you able to upload other code to ATTiny45? Are you unable to compile this particular code? Or you can compile it but it does not work? What it does and what it should do?
How dare you assume I have done nothing to find out what's going wrong! I've asked for help and all you are doing is being argumentative in not understanding a simple request
 I don't understand the library enough to make changes to it, but I do know it DOES NOT run on a attiny45 chip but DOES on the mega.

If your too closed minded to understand the entire code loads to the chip but the library isn't working on it then go away and let someone else help who understands what's going on. I can't stand arrogant people who just assume the error is with me. How is it I can load up any other sketch to the chip and that work fine but this one doesn't?! I'm doing what's right but your being stubborn and not appreciating that there IS intact a compatibility issue somewhere between the library and chip. So go away
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 07:05 pm
And I already stated the remainder of the code loads to the chip and works but the library for Morse doesn't.

Clear observation you didn't pay attention
Title: Re: attiny selection hardware multiplier
Post by: PerryBebbington on Nov 16, 2019, 09:08 pm
Hello secretreeve,

May I suggest that you consider for a moment that the people here answering questions and providing help are doing so as volunteers and are doing their best to help others learn about electronics and micro controllers. The answers Smajdalf has given you might not be what you were hoping for but I sure they are his best attempt to help you. Being rude to him is hardly going to encourage him or anyone else to give you the help you need.

Thank you.
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 09:19 pm
Hello secretreeve,

May I suggest that you consider for a moment that the people here answering questions and providing help are doing so as volunteers and are doing their best to help others learn about electronics and micro controllers. The answers Smajdalf has given you might not be what you were hoping for but I sure they are his best attempt to help you. Being rude to him is hardly going to encourage him or anyone else to give you the help you need.

Thank you.
Hello secretreeve,

May I suggest that you consider for a moment that the people here answering questions and providing help are doing so as volunteers and are doing their best to help others learn about electronics and micro controllers. The answers Smajdalf has given you might not be what you were hoping for but I sure they are his best attempt to help you. Being rude to him is hardly going to encourage him or anyone else to give you the help you need.

Thank you.
I wasn't being rude, I was simply trying to reiterate that the problem is in the chip is incompatible and that I don't appreciate him not paying attention to what has already been stated. If the original question had actually been addressed then there wouldn't be an issue. I stated a question and got insulted by being told I was doing something wrong. Don't single me out because i stuck up for myself and asked someone to leave me alone unless they was addressing the original question
Title: Re: attiny selection hardware multiplier
Post by: Coding Badly on Nov 16, 2019, 09:26 pm
Good luck, Barry
Barry is dispensing bad advice.  Stay away from Barry.

Title: Re: attiny selection hardware multiplier
Post by: Coding Badly on Nov 16, 2019, 09:27 pm
The compiler does nothing to compensate for anything
Post the error message(s).  Please use code tags.

Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 16, 2019, 09:35 pm
Post the error message(s).  Please use code tags.


There is no error messages. This is the thing, the code compiles and run on the arduino, I.e my code and the Morse code using Morse library.
As soon as it's loaded into the attiny45 my code runs fine but the Morse doesn't function.

I have led flashers and other stuff going on as well as the Morse code, all the leds wrote high and flashers run but no Morse code when loaded up. I've checked the pins and everything with it. The library has to be the problem in relation to the chips abilities. Perhaps the arduino has an extra something that's allowing it to run?

So there is no error messages or anything to post up. Sorry.

I'll load JUST the Morse into a chip when I get home later and see what happens buy will8ng to get it compiles and loads bit doesn't run
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 17, 2019, 12:29 am
well god knows whats going on, the more advanced version of the same code actually functions perfectly fine on an attiny85 (needed the 85 for flash size)

so i dont understand whats going on as the basic version is the same code with other led commands pulled out.

oh well, i'll work it out later.

thanks for the assistance.
Title: Re: attiny selection hardware multiplier
Post by: westfw on Nov 17, 2019, 12:32 am
Maybe you ran out of RAM at runtime.  The t85 has more RAM than a t45. (and both have significantly less than a m328)

Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 17, 2019, 12:35 am
Maybe you ran out of RAM at runtime.  The t85 has more RAM than a t45. (and both have significantly less than a m328)


is there anyway within the arduino software to check how much a sketch requires? it would be good to examine this and have a look and would advance my own knowledge significantly in the future.

i suppose a cheap and nasty way would be to load the simpler sketch to the 85 and see if it runs but it would be good if there was an option within avr or something.
Title: Re: attiny selection hardware multiplier
Post by: CrossRoads on Nov 17, 2019, 12:46 am
Anytime you compile, the IDE reports how much is used.

Example from a '328P (Uno):
Sketch uses 5604 bytes (17%) of program storage space. Maximum is 32256 bytes.
Global variables use 575 bytes (28%) of dynamic memory, leaving 1473 bytes for local variables. Maximum is 2048 bytes.


The first line is flash memory, which the is the 32K of storage available less the bootload code (hence the maxiimum is less than 32 * 1024, or 32768).
The second line is static RAM, where the variables and the registers that are changed as the program runs are stored.
Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 17, 2019, 12:49 am
it was within limits then. otherwise it kicks up an error was sitting about 86% oh well i got a work around for the simpler one using want states and flasher with digital write. and the more complex variant works so i guess it can be considered a win as theres no change in form factor or size and none in cost really either.
Title: Re: attiny selection hardware multiplier
Post by: westfw on Nov 17, 2019, 12:52 pm
Quote
it was within limits then. otherwise it kicks up an error was sitting about 86%
The memory usage reported by the IDE is only the "static" (compile-time) memory used.  More memory gets used at run-time, and 86% reported usage on a part with only 256 bytes of RAM is probably way too much.
What's that leave ?  35 bytes for all the run-time consumption?  Ouch.

Title: Re: attiny selection hardware multiplier
Post by: secretreeve on Nov 17, 2019, 04:16 pm
thats a fair point, i wasnt aware it was static ram usage. lesson learnt? use the 85 isntead of 45 as its just easier to work with larger overheads haha