Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
How to synchronize Timer1.pwm()?
2015 年 11 月 28 日
01:02:53
zerozaber
Moderator
Forum Posts: 52
Member Since:
2015 年 02 月 11 日
Offline

Suppose I use 50 microseconds pwm wave. I want the start time of on-cycle of 2nd pin to be 25us after the start of the 1st pin. How can I do that? Also, is it possible to change to wave mode which start with off-time and follows by on-time?

Also I have other questions to ask
2. If I overclocked to 500Mhz (with extra cooling and power supply) can I still use function such as micros() or Timer1? if I want cycle of Timer1 to be 30us, do I have to call Timer1.initialize(50) or Timer1.initialize(30)? Also, are all 86duino library support overclocking?

3. for fast port writing, do I have to call disable interrupt before and restore interrupt after even I haven't use interrupt code? (such as in digitalWrite and digitalRead) I found that digitalWrite has these codes before and after outpb()

4. Is there any background program running when I use 86duino IDE to program? If there is, what is the longest time my code may be interfered?

2015 年 12 月 08 日
16:07:44
Android_Lin
Moderator
Forum Posts: 208
Member Since:
2014 年 04 月 01 日
Offline

zerozaber said
Suppose I use 50 microseconds pwm wave. I want the start time of on-cycle of 2nd pin to be 25us after the start of the 1st pin. How can I do that? Also, is it possible to change to wave mode which start with off-time and follows by on-time?

Hi, zerozaber:

You can try to call delayMicrosenconds(25) between the start of on-cycle of 2nd pin and the start of the 1st pin.

Also I have other questions to ask
2. If I overclocked to 500Mhz (with extra cooling and power supply) can I still use function such as micros() or Timer1? if I want cycle of Timer1 to be 30us, do I have to call Timer1.initialize(50) or Timer1.initialize(30)? Also, are all 86duino library support overclocking?

Yes, 86Duino library will get this information when initializing, if CPU is overclocked to 500Mhz, there is not effect for using, we can directly call delay(), micros(), and Timer1.initialize(30), don't modify or re-calculate time by ourselves.

3. for fast port writing, do I have to call disable interrupt before and restore interrupt after even I haven't use interrupt code? (such as in digitalWrite and digitalRead) I found that digitalWrite has these codes before and after outpb()

The GPIO ports are common resources on 86Duino, if we want to call digitalWrite() in ISR and main program, disable/enable interrupt will avoid interference when accessing. For fast port writing, don't need to add disable/enable interrupt if haven't use interrupt code, but i still recommend to add them because i may forget to modify code if add interrupt code (ISR) in the future, and additionally it doesn't spend much time to call.

4. Is there any background program running when I use 86duino IDE to program? If there is, what is the longest time my code may be interfered?

When uploading the program to 86Duino board, the running program is under a single tasking OS (FreeDOS), there are some drivers and BIOS services running in the background, but your program will not be affected too much.

2015 年 12 月 08 日
17:47:53
zerozaber
Moderator
Forum Posts: 52
Member Since:
2015 年 02 月 11 日
Offline

1. I have try delayMicroseconds() to set phase before, not work as it is very hard to set phase of all PWM. Sometimes, using delayMicroseconds(25) and delayMicroseconds(26), the pulse did not shifted exactly by 1 us (sometimes it shifted by 10 us). It looks like some services took the time to do other thing and my timing became wrong. I would like to know other way to do it exactly.

4. I still would like to know what is the time of longest service that my code may be interfered? is it more than 5 us?

Also, is Encoder in AB_PHASE_x2 use interrupt?

Forum Timezone: Asia/Taipei

Most Users Ever Online: 66

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Dinosaur: 27

leutenecker: 13

mrZagg: 10

lukeross: 8

tomka: 8

smeezekitty: 8

hippy: 8

Ekkehard: 8

UIdahoCIT: 8

blaxxun: 7

Member Stats:

Guest Posters: 0

Members: 1509

Moderators: 14

Admins: 5

Forum Stats:

Groups: 2

Forums: 10

Topics: 238

Posts: 1079

Newest Members: Carol Chou, Kai-Jung Chou, 1789, RegLiu, ameerawwad, asmanko, nekotwingo, ttronic, Davidpag, zaskia12

Moderators: Glaux: 70, uaa: 11, guigra: 17, asian55: 22, Android_Lin: 208, bcarroll: 12, cucubutter: 84, recycled-air: 12, stevemork: 16, zerozaber: 52, pongraczi: 20, George Andrews III: 56, poto: 11, garpastym: 20

Administrators: eveshih: 1, anthony: 31, viky6: 0, roboard: 135, hcl: 0