Thanks for your reply!
It seemed to be a hardware problem (not correctly connected to the I/O pins).
Right now, I am trying to send a char using RS-485 (4 wires). So, I have Rx, Tx, RxEnable, TxEnable. Maybe you can give a hint regarding this topic because I think I missed something (based on the fact I am a beginner with MQX).
I have the defines :
#define TxPin BSP_TX#define RxPin BSP_RX#define Tx_Enable BSP_TX_ENABLE#define Rx_Enable BSP_RX_ENABLE
Initialize function :
boolean InitializeIO(void) { const uint_32 output_set[] = { TxPin | GPIO_PIN_STATUS_0, Tx_Enable | GPIO_PIN_STATUS_0, Rx_Enable | GPIO_PIN_STATUS_0, GPIO_LIST_END }; const uint_32 input_set[] = { RxPin, GPIO_LIST_END }; /* Open and set port as output */ output_port = fopen("gpio:write", (char_ptr) output_set); /* Open and set port as input to read value from Rx pin*/ input_port = fopen("gpio:read", (char_ptr) input_set); if (output_port && input_port) return (input_port!=NULL) && (output_port!=NULL); else return 0;} Then I am trying to setup the outputs (for transmitting - RxEnable 1 and TxEnable 1 :
void SetOutput(int signal)
{
uint_32 set_value=0;
static const uint_32 Send[] = {
TxPin,
GPIO_LIST_END
};
static const uint_32 SendEnable[] = {
Tx_Enable,
GPIO_LIST_END
};
static const uint_32 ReceiveEnable[] = {
Rx_Enable,
GPIO_LIST_END
};
if(output_port)
{
switch(signal)
{
case 1: ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &Send);
case 2:
{
ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &SendEnable);
ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, (pointer) &ReceiveEnable);
}
}
}
} And the trying to send the character :
int SendChar(uchar c){ _mqx_int error=0; SetOutput(2); ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, NULL); error = fputc(c,output_port); _time_delay(100); return error;}
Any hint ? What I am doing wrong ?
Many thanks