2019-07-04 12:22 AM
Dear Members,
I tried to talk with SIM7600 using UART1,
The code was working ok with SIM900,
Now,it's giving me the result but it's not right,
Is it because of baudrate ? it was 19200 for SIM900
and now 115200 for SIM7600
the code :
void test_modem (void)
{
char rx_data[5];
int x;
printf("TEST SIM7600SA-H\r\n");
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer, sizeof(aTxBuffer));
HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,1);
HAL_Delay(5000);
HAL_UART_Transmit_IT(&huart1,(uint8_t*)&aTxBuffer2,sizeof(aTxBuffer2));
HAL_UART_Receive_IT(&huart1, (uint8_t *)&SIM900.rxBuffer,1);
HAL_Delay(5000);
//scanf(rx_data,"OK \r\n");
}
callback
void SIM900_CallBack(void)
{
SIM900.LastTime=HAL_GetTick();
if(SIM900.rxIndex < sizeof(SIM900.rxBuffer)-2)
{
SIM900.rxBuffer[SIM900.rxIndex] = SIM900.rxTmp;
SIM900.rxIndex++;
memcpy((void *)line_buffer_SIM900, SIM900.rxBuffer, SIM900.rxIndex);
}
HAL_UART_Receive_IT(&_SIM900_USART,&SIM900.rxTmp,1);
printf("%s",line_buffer_SIM900);
}
on main :
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART2)
{
.
.
}
if(huart->Instance==USART1)
{
SIM900_CallBack();
GPS_Flag=0;
}
UartReady = SET;
}
Any clues or pseudo code ? thanks
2019-07-04 12:23 AM
output from SIM
TEST SIM7600SA-H
AT
RMn GATATP CATATATAT_GATATATATIATAT.ATAT8ATAT7ATAAT
RMn GATATP CATATATAT_GATATATATIATAT.ATAT8ATAT7ATATAT
RMn GATATP CATATATAT_GATATATATIATAT.ATAT8ATAT7ATATAAT
RMn GATATP CATATATAT_GATATATATIATAT.ATAT8ATAT7ATATAT============
2019-07-04 06:15 AM
I transmit these variables :
uint8_t aTxBuffer[] ="ATI\r";
uint8_t aTxBuffer2[] = "AT\r";
2019-07-04 06:26 AM
Doing printf of unbound strings in a callback or interrupt is inadvisable, likely taking multiple byte times.
2019-07-04 06:39 AM
Thanks for the reply,
then how can I print the received message?
Pseudo code or example ? I have made another process, but it must be called from callback....is it ok ?
2019-07-04 06:45 AM
Perhaps buffer the messages you want to send, and then dispatch in the foreground while you do the 5 second wait.
Remember also that C strings need to be properly NUL terminated.
2019-07-04 07:01 AM
Remember also that C strings need to be properly NUL terminated.....
" NUL terminated " ... \0 on my transmitter command ?
so "AT\r\0" ?
2019-07-04 07:20 AM
is it possible there's an issue with voltage level and grounding ?
I used a power from Desktop USB with a different port and from the documentation, it needs 1.83V max...
2019-07-04 07:22 PM
uint8_t aTxBuffer[] ="ATI\0\r";
uint8_t aTxBuffer2[] = "AT\0\r";
??