[gnea/grbl-Mega Issue#78] Swaping Spindle PWM pin

未分类 bolang 3个月前 (10-15) 23次浏览

Issue #78 | 状态: 已关闭 | 作者: WD24 | 创建时间: 2018-10-24


Hi
I’m trying to swap the spindle PWM pin from timer4B to timer3B. I would eventually like to port GRBL on to an ATmega2561 which is basically the same as the ATmega2560 but with less pins.

Iam currently testing all this on an arduino mega.

However changing the macros in cpu_map.h to refer to timer 3B, gives no output on PE4. I’ve also tried timer3C and again no output on PE5. I can move it to timer4C (PH5) and timer5B (PL4) sucessfully.

If I try a timer code using GRBL syntax in an empty sketch it works on all 16bit timers on my arduino mega.

I’ve read knightmg1983 ‘s (issue #52 Spindle PWM Pin swap) the’ve swaped the timer to mode14 and on to timer4A, it hasn’t helped me.

Is there any function elswhere blocking access to timer3x or to port E?

Thank you for any help you can offer.

my adjustments to cpu_map.h are:

#define SPINDLEDIRECTIONDDR DDRE
#define SPINDLEDIRECTIONPORT PORTE
#define SPINDLEDIRECTIONBIT 3 //free up PE4 move to MEGA2560 Digital Pin 5

#define SPINDLETCCRAREGISTER TCCR3A
#define SPINDLETCCRBREGISTER TCCR3B
#define SPINDLEOCRREGISTER OCR3B
#define SPINDLECOMBBIT COM3B1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLETCCRAINIT_MASK ((1<TCCRBINIT_MASK ((1<OCRAREGISTER OCR3A // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLEOCRATOPVALUE 0x0400 // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLEPWMDDR DDRE
#define SPINDLEPWMPORT PORTE
#define SPINDLEPWMBIT 4 // MEGA2560 Digital Pin 2


评论 (1)

#1 – WD24 于 2018-10-26

So Timer 0 & 1 are linked in with stepper functions, timer3 is linked in with the sleep function.

What I did was to move the timer macros for timer3 in sleep.c to refer to timer5.
now I can move the spindle_PWM pin on to timer3 and on to pin PE4. with the code above

It was only a quick test as its late, but it seems to work.


原始Issue: https://github.com/gnea/grbl-Mega/issues/78

喜欢 (0)