Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
Hi

I am trying to generate some kind of signal on a particular pin. Part of that signal should be generated by ordinary GPIO actions and part of that signal should also be generated by UART.
In fact, I am trying to implement the DMX512 protocol.

What I currently do is the following:

My GPIO configuration is for pin 5.1
My UART configuration is also set for pin 5.1 , but with configuration mode equal to XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT1

I can generate the BREAK and MAB signals correctly.
Sending the data over uart seems to be working too, except when I have sent my last uart frame it seems that the stop-bits are lost.
In the ISR 'dmx512_slotTransmittedInterruptHandler', I check if the last slot is sent and set everything back such that the BREAK is sent again.

void dmx512_interruptHandler(void)
{
TIMER_ClearEvent(&TIMER_0);

if (dmx512_state == TRANSMIT_MAB) {
TIMER_Stop(&TIMER_0);
TIMER_SetTimeInterval(&TIMER_0, 1200); // MAB = 12us
TIMER_Start(&TIMER_0);
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_0);
dmx512_state = PREPARE_SLOTS;
}
else if (dmx512_state == PREPARE_SLOTS) {
current_slot = 0;
TIMER_Stop(&TIMER_0);
TIMER_SetTimeInterval(&TIMER_0, 4400); // SLOT = 44us
TIMER_Start(&TIMER_0);
XMC_GPIO_Init(UART_0.config->tx_pin_config->port, UART_0.config->tx_pin_config->pin, UART_0.config->tx_pin_config->config);
dmx512_state = TRANSMIT_SLOTS;
}
else if (dmx512_state == TRANSMIT_SLOTS) {
UART_Transmit(&UART_0, &slot_data[current_slot], sizeof(slot_data[current_slot]));
}
}

void dmx512_slotTransmittedInterruptHandler(void)
{
UART_ClearFlag(&UART_0, XMC_UART_CH_STATUS_FLAG_TRANSMITTER_FRAME_FINISHED);
if (++current_slot > NUMBER_SLOTS) {
dmx512_state = TRANSMIT_BREAK;
}
}


int main(void)
{
...
dmx512_state = TRANSMIT_BREAK;

while(1U)
{
switch(dmx512_state)
{
case TRANSMIT_BREAK:
start();
break;
default : break;
}
}
}

void start()
{
current_slot = 0;
DIGITAL_IO_Init(&DIGITAL_IO_0);
TIMER_Stop(&TIMER_0);
TIMER_SetTimeInterval(&TIMER_0, 17600); // BREAK = 176us
TIMER_Start(&TIMER_0);
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_0);
dmx512_state = TRANSMIT_MAB;
}



I sent data for 3 slots (values 1 , 2, 3).
This is my signal. As you can see, the last slot has no stop-bits:

2316.attach

Is there someone who can help me. I'm struggling for it for a while already.
0 Likes
0 Replies