I am really struggling to establish communication between Tiva C TM4C123GH6PM microcontroller to use Dynamixel servo. Here is the circuit where MAX485 converts UART TTL signal to RS485. This servo has a protocol structure for communication. link for that is
The Transmit enable pin i control it using a GPIO pin and TX pin and Rx pin is connected to uC. I am sending out the Data but I do not get any response from the Servo until i terminate the code. for my code I used bit of Dynamixel servo provided SDK and made some changes so it would run on Code composer studio (eliminating Windows API funcs and writing equivalent code).
On the oscilloscope, i have this transmit and receive this but only when i terminate the code and the code just goes into a blocking function (UARTCharGet a blocking function) And never comes back from it as it says that dynamixel did not send any data back and FIFO or (Receive line is just empty)
int writePortArm(int port_num, uint8_t *packet, int length)
{
//Set to transmit mode
int iWrite = 0;
//GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_PIN_4);
//GLOBAL_SetSysFlag(SYSFLAGS_EOP);
while(length)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_PIN_4);
GLOBAL_SetSysFlag(SYSFLAGS_EOP);
UARTCharPut(UART0_BASE,(char)*packet);
*packet++;
length--;
iWrite++;
}
//Clear the Flag (End of packet)
// GLOBAL_ClearSysFlag(SYSFLAGS_EOP);
//Switch to receive mode
// GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_4,0);
return iWrite;
}
int readPortArm(int port_num, uint8_t *packet, int length)
{
int iRead = 0;
//do the Read
while(length)
{
//uint8_t readX = UARTCharGet(UART0_BASE);
*packet = (char)UARTCharGet(UART0_BASE);
*packet++;
length--;
iRead++;
}
return (int)iRead;
}
i am using Dynamixel SDK https://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_sdk/api_reference/c/c_porthandler/#c-porthandler
I AM converting this base code for supporting Tiva Microcontroller.