View previous topic :: View next topic |
Author |
Message |
zebelxan
Joined: 19 Apr 2017 Posts: 2
|
Posted: Wed Apr 19, 2017 8:36 pm Post subject: problem about config timer1 and timer3 on pwm mode(ATmega128 |
|
|
hello dear friends;
i have a problem on bascom with making same pwm from timer1 and timer3 ( Both are 16Bit) But before asking i think its better i say that i am new to electronics and bascom.
i want to control speed of 4 DC Motor using " ATmega1284p + L298N "
however i have same config for both timers but the result pwm is different with each other.
i need all of that 4 produced signals be same.(duty cycle= 50%==> like timer3 signals)
this image is showing my question clearly:
http://uupload.ir/files/7lr3_capture1.png
and this is bascom code:
Code: |
$regfile = "m1284pdef.dat"
$crystal = 8000000
'#16bit:
Config Timer1 = Pwm , Pwm = 8 , Prescale = 256 , Compare_A_Pwm = Clear Up , Compare_B_Pwm = Clear Up
Config Timer3 = Pwm , Pwm = 8 , Prescale = 256 , Compare_A_Pwm = Clear Up , Compare_B_Pwm = Clear Up
Enable Interrupts
Enable oc1a
Enable oc1b
Enable oc3a
Enable oc3b
Enable Timer1
Enable Timer3
Config Porta = Input 'Controller Commands
Config Portc = Output 'Pins To L298 Driver
'#pwm
Config Portd.5 = Output 'PWM1A
Config Portd.4 = Output 'PWM1B
Config Portb.6 = Output 'PWM3A
Config Portb.7 = Output 'PWM3B
'Normal Start
Pwm1a = 125
Pwm1b = 125
Pwm3a = 125
Pwm3b = 125
'Pins To L298 inputs:
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
Portc.4 = 0
Portc.5 = 1
Portc.6 = 0
Portc.7 = 1
|
please help.
Best Regards.
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Thu Apr 20, 2017 2:06 am Post subject: JTAG fusebits? |
|
|
Have you checked the JTAG fusebit settings? |
|
Back to top |
|
|
zebelxan
Joined: 19 Apr 2017 Posts: 2
|
Posted: Thu Apr 20, 2017 8:26 am Post subject: i am new to bascom |
|
|
dear friend thanks for reply.
i am new to bascom and the code above is all my bascom project code. |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Thu Apr 20, 2017 10:39 am Post subject: Fuses |
|
|
There are some 'fuses' inside the microcontroller. To handle internal or external crystal, bootloader, speed of booting etc. One of these fuses enable/disable JTAG. If the JTAG is enabled some of the Portc pins will work different. So you will have to disable JTAG.
Do a small search in this forum about JTAG and fuses. It is always nice to know how these fuses are set. For instance the atmega88 can be shipped from factory running on a 8 Mhz internal RC clock but divided by 8. So running on 1 Mhz.
Have fun
Ben Zijlstra |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
|