engr_joni_ee
Advanced Member level 3
I am using PIC18F. I am wondering if anyone has tried to get string using this function which is generated in the MCC in MPLAB.
I have made the following function outside the main() that calls the MCC generated function "EUSART1_Read()". I need to get a string basically through the following function but this has some issues that involves return types and assignments. Can someone please have a look and help me to resolve the issue in receiving the string using the MCC generated function.
I need to call this function in the main() function but it says that rx_string is not assignable.
Even if I define rx_string as uint8_t, the problem is the same. Somewhere I am not using the correct data type and return type.
Code:
uint8_t EUSART1_Read(void)
{
while(!PIR1bits.RC1IF)
{
}
eusart1RxLastError.status = 0;
if(1 == RCSTA1bits.OERR)
{
// EUSART1 error - restart
RCSTA1bits.CREN = 0;
RCSTA1bits.CREN = 1;
}
return RCREG1;
}
I have made the following function outside the main() that calls the MCC generated function "EUSART1_Read()". I need to get a string basically through the following function but this has some issues that involves return types and assignments. Can someone please have a look and help me to resolve the issue in receiving the string using the MCC generated function.
Code:
char EUSART_Read(void)
{
int i = 0;
char rx = 'a';
char rx_string[10];
while (rx != 0x0d)
{
rx = EUSART1_Read(); // Return type of this function is uint8_t
rx_string[i] = rx; // store the data in string
i++;
}
return rx_string;
}
I need to call this function in the main() function but it says that rx_string is not assignable.
Code:
rx_string = EUSART_Read();
Last edited: