Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

ATtiny85 PWM on D4

3 posters

Go down  Message [Page 1 of 1]

1ATtiny85 PWM on D4 Empty ATtiny85 PWM on D4 Fri Apr 28, 2023 11:16 am

KarstenLehmann



I am afraid, I found a bug in ATtiny85…?!?
By happenstance I found a circuit of a cross-fade blinker, created for railroad crossing of a model railway. The producer develope and tested this on the original ATtiny85-chip. He uses D0 and D4 and this works fine.
As I reproduce the circuit in SimulIDE, D0 works perfect, but not D4…?!?
I try several actual releases, but with the same result. When I try this with D0 and D1, it works.

I think, a little mistake has slipped in?!?

Attachments
ATtiny85 PWM on D4 AttachmentATTiny85_PWM_D4_problem.zip
You don't have permission to download attachments.
(13 Kb) Downloaded 5 times

2ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Fri Apr 28, 2023 3:21 pm

arcachofo

arcachofo

Thanks, I will have a look.

KarstenLehmann likes this post

3ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Sat Apr 29, 2023 12:46 pm

arcachofo

arcachofo

Your code is working for me if I compile it (ATTiny85_pin04_no_PWM.ino).

Are you sure you are compiling it for AtTiny85?

KarstenLehmann likes this post

4ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Sun Apr 30, 2023 10:44 am

KarstenLehmann



I use a standard installation of Arduino 1.8.19 on ubuntu 18.04

my settings:
board: ATtiny25/45/85
prozessor: ATtiny85
clock: internal 1MHz

different projects run perfect with this settings…
Please correct me if I am wrong!

5ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Sun Apr 30, 2023 11:08 am

arcachofo

arcachofo

Weird...
If I run ATTiny85_pin04_no_PWM.sim1, which uses ATTiny85_pin04_no_PWM/ATTiny85_pin04_no_PWM.ino.tiny8.hex
OCR1C is always 0 and PWM at PORTB4 does not work.

If I compile ATTiny85_pin04_no_PWM/ATTiny85_pin04_no_PWM.ino for Attiny85 then OCR1C = 255 and PWM at PORTB4 works as expected.
Hex file attached.
Attachments
ATtiny85 PWM on D4 AttachmentATTiny85_pin04_no_PWM.hex.zip
You don't have permission to download attachments.
(2 Kb) Downloaded 1 times

KarstenLehmann likes this post

6ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Sun Apr 30, 2023 11:59 am

KarstenLehmann



here the left led seems to be continuous ON – didn't fade. Look at the screenshot.

But now, when I use your hex-file, it fades – slowly, but it fades! When I change the setting from 1MHz to 8MHz, your  hex-file works perfect!
Please excuse me! Apparently it is my mistake…?!? :-/

ATtiny85 PWM on D4 Attiny10

arcachofo likes this post

7ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Sun Apr 30, 2023 7:46 pm

KarstenLehmann



Now I tried to compile with ATtinyCore (8MHz/16MHz) and it works!

Did anyone know:
is it wrong to use PWM with 1MHz…???

8ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Mon May 01, 2023 11:32 am

arcachofo

arcachofo

is it wrong to use PWM with 1MHz…???
In theory you can use PWM with any frequency, but who knows what these libraries are doing.

KarstenLehmann likes this post

9ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Mon May 15, 2023 5:31 pm

Mr_IODA



Hello !

I'm also stuck with my pwm exploration and learning !
I cannot make even a simple sketch to work :-(

here is my minimal test code the sim file is attached.

void setup() {
   // Minimal attiny timer1 setup for PWM exploration
   // set PB1 (OC1A) as output
      DDRB |= (1 << DDB1);
      TCCR1=0;
      OCR1A = 127; // Set Duty cycle baseline half OCR1C for 50%
      OCR1C = 255; // Set Ouput frequency must be calculate as needed
      // Timer settings for PWM
      TCCR1 = (1 << PWM1A) | (1 << COM1A1) | (1 << CS10);
}

// the loop function runs over and over again forever
void loop() {
}

I use the  1.0.0-SR0 R1320 version of SimulIDE under Windows 11.
This code works perfectly on a real attiny85.

Does it possible to test PWM configuration with SimulIDE or is it really a confirmed bug ?

regards

10ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Tue May 16, 2023 4:50 pm

arcachofo

arcachofo

I think you need to compile your project for ATtiny85.
The simplest way todo it is using Arduino IDE.

Or have a look at this discussion: https://simulide.forumotion.com/t323-attiny85-load-program

Mr_IODA likes this post

11ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Tue May 16, 2023 7:46 pm

Mr_IODA



arcachofo wrote:I think you need to compile your project for ATtiny85.
The simplest way todo it is using Arduino IDE.

Or have a look at this discussion: https://simulide.forumotion.com/t323-attiny85-load-program

Hello !

In fact i've already tried this and used the hex file produced by arduino IDE. it gave me the same result !

But i've perhaps missed something ! So i will read the thread you suggest, give arduino IDE an other try and tell you back !

Regards

arcachofo likes this post

12ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Mon May 22, 2023 9:19 pm

Mr_IODA



arcachofo wrote:I think you need to compile your project for ATtiny85.
The simplest way todo it is using Arduino IDE.

Or have a look at this discussion: https://simulide.forumotion.com/t323-attiny85-load-program

Hi,

I've try many ways as you suggest but with no results with 1.0.0
So i give 0.4.15 a try ... and its a bit better but not really fine  Crying or Very sad

With 1.0.0 i could setup CTC mode but no way to toggle PB1 despite the fact i set the COM1Ax and others bits correctly.

with 0.4.15 the PB1 toggle but it's not possible to set OCR1A and OCR1C. Setting differents values do not change the frequency and the duty cycle still freeze at 50%. Only the prescaler adjustement have an effect on the frequency, for sure !

I not able to determine exactly what'is going wrong.

I've notice that the SRAM adress of registers is shifted by 22(decimal) in the MCU monitor as all the other registers even if the "C:\SimulIDE_0.4.15\share\simulide\data\avr\attiny85.data" file contains   the non shifted definition  OCR1A EQU 46 -> 0x2E OCR1C EQU 45 -> 0x2D wich are the values we can found in the datasheet ...
In MCU monitor it's clearly 0x4D and 0x4E i've also wrote addresses and values of OCR1A and OCR1C in EEPROM to confirm.

EEPROM.write(0, &OCR1A);
EEPROM.write(1, OCR1A);
EEPROM.write(2, ocr1aAddress);
value = *ocr1aAddress; //0x2E
EEPROM.write(3, value);
 EEPROM.write(4, ocr1aAddress2);
value = *ocr1aAddress2; //0x4E
EEPROM.write(5, value);

EEPROM.write(6, 0xFF);
EEPROM.write(7, 0xFF);

EEPROM.write(8, &OCR1C);
EEPROM.write(9, OCR1C);
EEPROM.write(10, ocr1cAddress);
value = *ocr1cAddress; //0x2E
EEPROM.write(11, value);
EEPROM.write(12, ocr1cAddress2);
value = *ocr1cAddress2; //0x4E
EEPROM.write(13, value);

ATtiny85 PWM on D4 Simuli10

Do you think it's a direction ? IMHO there is some trouble anyway with timer1 simulation in both versions, dont you think so ?

Regards

13ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Mon May 22, 2023 11:22 pm

arcachofo

arcachofo

I didn't realize you are not using the last build for 1.0.0.
Try with the last one available here:
https://simulide.forumotion.com/t390-simulide-1-0-0-tester-builds#1936

Mr_IODA likes this post

14ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Tue May 23, 2023 2:40 pm

Mr_IODA



arcachofo wrote:I didn't realize you are not using the last build for 1.0.0.
Try with the last one available here:
https://simulide.forumotion.com/t390-simulide-1-0-0-tester-builds#1936

Dear arcachofo,

You are the champion Cool

I didn't have much time to do extensive testing but, with this version, it works Very Happy

The output frequencies are now accurate based on the timer, prescaler and duty cycle register settings.

Thanks a lot for your time and work!
Since I discovered SimulIDE, I have been looking forward to it.
It is a very nice tool, for education and personal research, at almost no cost. Keep pushing!

Thanks again, best regards

15ATtiny85 PWM on D4 Empty Re: ATtiny85 PWM on D4 Wed May 24, 2023 1:26 am

arcachofo

arcachofo

Glad to know that it is working now.

And sorry for not putting enough attention, I was convinced that you were using the last build.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum