ik ben al even bezig met op mijn easypic6 de cog_lcd en de RS232 functies aan het testen. Nu wil ik via RS232 de tekst doorsturen naar mijn PIC, maar dit wilt niet lukken.
UART via hypertrm en COG_LCD werken apart prima.
Volgens mij ligt het aan het feit dat mijn tekst binnenkomt in een short, en moet buitengaan als een array van chars?
nu heb ik dit proberen om te zetten met een van de standaardfuncties van mikroC, maar dan krijg ik allerhande rare dingen te zien.
iemand een idee waar ik juist fout zit?
(sorry, newbie programmeur hier
programma:
Code: Selecteer alles
char *text = "standard";
unsigned short output;
// Port Expander module connections
sbit SPExpanderCS at RA2_bit;
sbit SPExpanderRST at RA3_bit;
sbit SPExpanderCS_Direction at TRISA2_bit;
sbit SPExpanderRST_Direction at TRISA3_bit;
// End Port Expander module connections
char i; // Loop variable LCD function
unsigned short j; // Loop variable UART function
void main() {
//config bits
ANSEL = 0; // Configure AN pins as digital
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
// uart init at 2400 baud
UART1_Init(2400); // Initialize USART module
Delay_ms(100);
// Port Expander Library uses SPI1 module
SPI1_Init(); // Initialize SPI module used with PortExpander
SPI_Lcd_Config(0); // Initialize Lcd over SPI interface
SPI_Lcd_Cmd(_LCD_CLEAR); // Clear display
SPI_Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
SPI_Lcd_Out(1,1, "UART TEST"); // Print text to Lcd, 1st row, 1st column
SPI_Lcd_Out(2,2, text); // Print text to Lcd, 2nd row, 2nd column
Delay_1sec();
while (1) {
if (UART1_Data_Ready() == 1) { // if data is received
UART1_Read_Text(output, "OK", 10); // reads text until 'OK' is found
UART1_Write_Text(output); // sends back text
shorttostr(output,text); //convert output
SPI_Lcd_Out(1,1, text); // Print text to Lcd, 1st row, 1st column
}
}
}