Hello,
I'm currently having trouble to set dynamic periods foe the GPT timer. Im trying to capture a protocol similar to UART / LIN which js called Bean MPX in Toyota cars. The implementation would require me to trigger a half bit period once a interupt happens on both edges.
I've had some success with dynamically chaning the ARR and disabling ARPE, but resulted in increased delays between the iterations. The only semi decent way was PWM and manipulating the CCR register, but trying the same on the GPT driver in continous and setting the output/capture mode didnt help.
Advice would be greatly apreciated.
GPT Driver dynamic period
Moderators: RoccoMarco, barthess
- Giovanni
- Site Admin
- Posts: 14486
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1088 times
- Been thanked: 928 times
- Contact:
Re: GPT Driver dynamic period
Hi,
Changing period is not immediate, it is "taken" on the next ARR match, probably this is what you are experiencing. You should consider doing a custom driver if you find yourself manipulating registers directly.
Giovanni
Changing period is not immediate, it is "taken" on the next ARR match, probably this is what you are experiencing. You should consider doing a custom driver if you find yourself manipulating registers directly.
Giovanni
Re: GPT Driver dynamic period
Thank You Giovanni.
One question regarding the PWM setup, I assume that pwmPeriodCallback and pwmEndCallback are each called at an 100uS interval, but which one of those is afected by the CCR[0] register? I want the handle_rx functions being called at 100uS and if neccessary I would adjust the CCR to trigger it at half (50uS)?
One question regarding the PWM setup, I assume that pwmPeriodCallback and pwmEndCallback are each called at an 100uS interval, but which one of those is afected by the CCR[0] register? I want the handle_rx functions being called at 100uS and if neccessary I would adjust the CCR to trigger it at half (50uS)?
Code: Select all
static void pwmPeriodCallback(PWMDriver *pwmp) {
(void)pwmp;
palSetPad(GPIOB, 5U);
BeanMPX::handle_rx(BeanMPX::getActiveObject());
BeanMPX::handle_rx_ack(BeanMPX::getActiveObject());
}
static void pwmEndCallback(PWMDriver *pwmp) {
(void)pwmp;
palClearPad(GPIOB, 5U);
}
static const PWMConfig pwmcfg = {
48000000,
4800,
pwmPeriodCallback,
{
{PWM_OUTPUT_ACTIVE_HIGH, pwmEndCallback},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL}
},
0,
0
};
pwmstart(&PWMD3, &pwmcfg);
pwmEnableChannel(&PWMD3, 0, 4800);
- Giovanni
- Site Admin
- Posts: 14486
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1088 times
- Been thanked: 928 times
- Contact:
Re: GPT Driver dynamic period
The periodic callback is just that, periodic.
The other callback is called on the deactivation front of a PWM channel, on CCR match.
Giovanni
The other callback is called on the deactivation front of a PWM channel, on CCR match.
Giovanni
Who is online
Users browsing this forum: No registered users and 12 guests