I am sorry about the location of the topic, i really couldn't decide where to put this so I hope here will be fine.
Hardware/Software description:
A. Clicker 2 for STM32 (STM32F407ZG) - Coded in MIKROC PRO for ARM - Programmed with CODEGRIP
B. MIKROMEDIA 7 Capacitive FPI with SIBRAIN STM32F767ZG (MIKROE 3476) - Coded in NECTO / MIKROC AI for ARM - Programmed with CODEGRIP
Target:
I want to obtain UART communication between these two devices.
Issue:
Reading data is never triggered.
Oscilloscope Channels description:
Channel 1(Upper signal on pictures) - TX of CLICKER 2 / RX of MIKRO7
Channel 2(Lower signal on pictures) - RX of CLICKER 2 / TX of MIKRO7
CLICKER2 for STM32 Code:
Code: Select all
//UART INITIALISATION ON Clicker2 for STM32 Board
UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD56);
UART_Set_Active(&UART2_Read, &UART2_Write, &UART2_Data_Ready, &UART2_Tx_Idle);
Delay_ms(500);
//END OF UART INITIALISATION
//<While 1 function in Main>
while(1)
{
OUT1_ON;
LD1=1;
Delay_ms(5);
ScanCycle();
LD1=0;
datac=0x7F;
UART2_Write(datac);
datac=0xCC;
UART2_Write(datac);
}
MIKRO7 Code for testing
Declarations:
Code: Select all
// UART driver context structure.
static uart_t uart;
// UART driver configuration structure.
static uart_config_t uart_cfg;
// Be careful to have large enough buffers.
static uint8_t uart_rx_buffer[128];
// Be careful to have large enough buffers.
static uint8_t uart_tx_buffer[128];
static size_t size;
Code: Select all
uart_configure_default(&uart_cfg);
uart_cfg.rx_pin = SHIELD_CONNECTOR_J2_PIN21;
uart_cfg.tx_pin = SHIELD_CONNECTOR_J2_PIN22;
uart_cfg.tx_ring_size = sizeof( uart_tx_buffer );
uart_cfg.rx_ring_size = sizeof( uart_rx_buffer );
// Initialize appropriate interrupt and allocate resources for UART module.
if ( uart_open( &uart, &uart_cfg ) == UART_ERROR )
{
showme2();// Error handling strategy
}
// Set baud rate.
if ( uart_set_baud( &uart, 115200 ) == UART_ERROR )
{
showme2();// Error handling strategy
}
Code: Select all
void application_task()
{
main_screen_show(&vtft);
vtft_process(&vtft);
// CYCLIC TX TEST
uart_tx_buffer[0]=0x7f;
uart_tx_buffer[1]=0xCC;
size=2;
size = uart_write( &uart, uart_tx_buffer, size );
Delay_ms(5);
// READ ATTEMPT
if ( uart_bytes_available( &uart ) )
{
size = uart_read( &uart, uart_rx_buffer, sizeof( uart_rx_buffer ) );
showme();
}
}
This is sufficient to say that both Boards / MCUs have properly initialized UART modules.
Both can Transmit and have the same Speed/Freq/Baud rate. Encoding is the same etc.
if ( uart_bytes_available( &uart ) ) on MIKRO7 was never triggered over counless variations of speed, baudrate, parity variations.
HARDWARE ISSUES
I can assure you all that the RX TX lines are crossed over between the devices and the connection is proper and good.
Both devices are on the same power supply, sharing GND.
Either way, oscilloscope captures can really rule out any wiring and pinout issues.
Can someone please give any clues on where i could be wrong and why my read function is never triggered?
Thank you all for taking time to read this.
Best regards,
Nermin