pwm problem with attiny13

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have problem with AVR Attiny13 that i want to run in mode 5 PWM . in pin5 -pb0 , i take only vcc but no pulses.. this is my code in assemby and i set the fuse "SUT_CKSEL" : INTRCOSC_9MHZ6_14CK_64MS... Where is my mistake ? Thank you in advance.

 .include"tn13def.inc"
 .cseg
 .org 0
 rjmp reset
reset:
ldi r16,low(ramend)
out spl,r16
 

 ldi r16,0xff
 out ddrb,r16
 
 

 ldi r16,0x81
 
 out tccr0a,r16
 ldi r16,0x0d
 out tccr0b,r16
 
 ldi r16,0x20
 
 out ocr0a,r16

e:
 
 rjmp e

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OCR0A is used to determine the count top. Therefore, PWM is not output to OC0A.
OCR0B is used to determine the duty. The PWM waveform is output to OC0B.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So , when i set TCCR0a as phase correct PWM and set COMOA1 :1 and COM0A0: 0 in oc0a i would not have clear on compare match when up-counting, and set oc0a on compare match when down-counting?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


athmio wrote:
i want to run in mode 5 PWM
What makes you choose that mode? It is:

 

 

The "issue" here is that "TOP" is OCR0A. The upside of that is that the frequency is variable. The downside, as kabasan says, is that if OCR0a is tied up being used to set the frequency then it is not available for setting duty - so channel A output is not available. If you want to use both A and B channels (but still phase correct) then use:

 

That is still "phase correct" but now the frequency (TOP) is fixed at 0xFF. As OCR0A is not "tied up" being used to set frequency then both channels A and B are available as output.

 

If the frequency really does need to be variable (and you must use phase correct) then you have to accept that only pin 6 (OCOB) can be used for a PWM output.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you very much ! but now i have a new question if i want pwm pase correct  and i use oc0a as top then i have to configure tccroa com0a1:0 too or only com0b1:0?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As we've said if you use a mode where TOP can be varied (by OCR1A) then that ties up OCR1A for that job. Therefore is cannot be used for its normal job (setting PWM duty on channel A) so channel A is completely unusable in such modes. So you can forget COM01A:0 and the OC0A pin (5) and so on as you've chosen a mode where they are not usable. You have ONE available PWm output and that is on pin 6 (OC0B). You will set the duty using OCR0B and configure the pin action using COM0B1:0

 

As I said above if you DO want to use output A (or maybe A and B ?) then you need to use mode 1 not mode 5 but it means the frequency will be fixed (TOP is fixed at 0xFF).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you !!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many times you do not need phase correct pwm.....some folks think the word 'correct' somehow means the other modes are 'incorrect', when they work just fine for many purposes.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

: [ERROR] Failed to enter programming mode. ispEnterProgMode: Error status received: Got 0xc0, expected 0x00, ModuleName: TCF (TCF command: Device:startSession failed.)

This is something else ! in order to have the frequency that i want i change the clock of the device from 4Mhz to 128khz ... i set the isp clock to 16khz but i have lost  the ability to enter in programme mode ...? why ? why that?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

athmio wrote:
i change the clock of the device from 4Mhz to 128khz

is the clock/8 fuse still set?  if so, your 128kHz is 16kHz so your isp clock is too fast.

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok i reduce to 2khz but ..nothing how can i change the fuse in the avr if it does not allow me to enter in programme  mode?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you post what you changed that started the problem, can you roll back and copy/paste what you did and the results?

We need to see what fuse settings you changed.

There are two other causes for this, no target power, or you disabled the reset pin via fuse setting.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i dont have the fuse file and the device does not allow me to enter.. is it possible to erase the device and bring back the initial fuses?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

athmio wrote:
is it possible to erase the device and bring back the initial fuses?

If all else fails, there is high voltage(12v) serial programming, only supported by some programmers, and only works if reset pin has nothing else connected that would be damaged by 12v?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So if somebody makes a mistake with the fuses then you loose the device?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

athmio wrote:
So if somebody makes a mistake with the fuses then you loose the device?

No any fuse mistake can be fixed, but may take using a different method then ISP.

You must always be careful when programming fuses, if you have any concerns, post what you want to do on AVRFreaks and someone will review it with you before you try to program them.

Also you should bookmark this site:  http://www.engbedded.com/fusecalc/

We all use it!

Also read the tutorial on how to recover your AVR here: https://www.avrfreaks.net/forum/...

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274