Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

PWM problems on atmega328

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Fri Jun 27, 2014 2:03 pm    Post subject: PWM problems on atmega328 Reply with quote

Hi,

I tried to use PWM (timer0) on atmega328. I didnt got any output on pwm. If I toggle the pin directly (toggle outputpin) I can change the level from low to high and high to low. But no PWM on this pin Sad

$crystal = 8000000
$regfile = "m328def.dat"
$baud = 38400
$hwstack = 300
$swstack = 300
$framesize = 300

Enable Interrupts

Config Pind.5 = Output

Config Timer0 = Pwm , Prescale = 1 , Compare B Pwm = Clear Up

Enable Timer0
Start Timer0

pwm0b =128

pind.5 keeps still low Sad

I used before atmega168 and this code worked well Sad

Has anybody an idea?

Cheers

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 932
Location: France

france.gif
PostPosted: Fri Jun 27, 2014 6:47 pm    Post subject: Reply with quote

hello,
Are you sure your fuse bits are the same setting ?

JP
Back to top
View user's profile Visit poster's website
Visovian

Bascom Member



Joined: 31 Oct 2007
Posts: 584
Location: Czech

czechrepublic.gif
PostPosted: Sat Jun 28, 2014 5:52 am    Post subject: Reply with quote

Bascom 2075 demo

Config Timer0 = Pwm , Prescale = 1 , Compare B Pwm = Clear Up
For mega328 this Config sets uncorrect values:
TCCR0A = 0
TCCR0B = 1

Try to set manually
Code:
'Config Timer0 = Pwm , Prescale = 1 , Compare B Pwm = Clear Up
Tccr0a = &H21
Tccr0b = 1

'Enable Timer0  'do not do this
'Start Timer0

pwm0b = 128
Back to top
View user's profile
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Sat Jun 28, 2014 1:46 pm    Post subject: Reply with quote

thank you very much . will try it on monday and will report .

cheers
Back to top
View user's profile
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Mon Jun 30, 2014 7:57 am    Post subject: Reply with quote

just tested it... it works... Thank you for your help!

Cheers
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum