Então, tô usando esse compilador novo, mas ta me dando uma dor de cabeça, gostaria de saber se alguem tá usando e tem alguma dica?
Estou usando um PIC18F452 à 8MHz e Baud Rate 9600.
- Código: Selecionar todos
UART1_Read_Text(RecvBuf, 0xF2, 10); // Lê Texto até que ETX seja encontrado
Descrição do HELP
void UART1_Read_Text(char *Output, char *Delimiter, char Attempts);
Reads characters received via UART until the delimiter sequence is detected. The read sequence is stored in the parameter output; delimiter sequence is stored in the parameter delimiter.
This is a blocking call: the delimiter sequence is expected, otherwise the procedure exits (if the delimiter is not found).
Parameters :
Output: received text
Delimiter: sequence of characters that identifies the end of a received string
Attempts: defines number of received characters in which Delimiter sequence is expected. If Attempts is set to 255, this routine will continuously try to detect the Delimiter sequence.
Ele lê o que vem da serial até encontrar 0xF2 ou até receber 10 caracteres, pelo que entendi.
O Comando UART1_Write_Text está funcionando perfeitamente, o problema é com o Read.
Primeiramente meu buffer RecvBuf não está recebendo nada dessa função.
Seguinte, quando envio para o uC 10 caracteres com o 0xF2 no meio, ele não sai fora da função, qdo envio novamente os mesmos 10 caracteres ele sai e o buffer fica vazio.
Qdo envio por exemplo, 2 caracteres entra não função e não sai, dae vou enviando +2, e mais, até qdo completa os 10 caracteres ae sai mas o buffer continua vazio, mesmo colocando nesses 2 caracteres o delimitador.
Exemplo do que está acontecendo, nessa caso o delimitador é "OK", e attemps é 10:
Sent: 1245OK - Enviei e não retornou nada
Sent: 1245OK - Enviei novamente...
Received: 121245 - Ae me retornou isso aqui.
- Código: Selecionar todos
if (UART1_Data_Ready() == 1 && Processo == 1)
{
UART1_Read_Text(RecvBuf, "OK", 10); // reads text until 'OK' is found
delay_ms(100);
UART1_Write_Text(RecvBuf);
alguem tem uma ideia, ou um outro modo sem usar essa função pra receber uma string pela serial.
Obrigado