#define XTAL_FREQ 4MHZ
#include <stdio.h>
#include <htc.h>
#include <pic.h>
#include <math.h>
#include "lcd.h"
#include "usart.h"
#include <string.h>
void main(void)
{
System_init(); // Calling System_Init Subroutine
INTCON=0; // purpose of disabling the interrupts
init_comms(); // set up the USART - settings defined in usart.h
init_adc(); // Calling init_adc Subrotine
lcd_init(); // Calling lcd_init defined in lcd.h
lcd_goto(0); // select first line in LCD
lcd_puts("Encoder:"); // display text in first line
lcd_goto(0x40); // Select second line
lcd_puts("Tempera: "); // display text in second line
Counter=0; // Setting the step counter as 0
temp=0;
while(1)
{
lcd_goto(0x48); // Select second line
display_value(Counter);
lcd_putch('C');
lcd_goto(0x08);
display_value1(Counter);
lcd_putch('m');
__delay_ms(100);
printf("\n%004d%%%04d\n", Counter,temp);
Counter=Counter+1;
} // End of While(1)
} // End of void(main)
#define BAUD 9600
#define FOSC 4000000L
#define NINE 0 /* Use 9bit communication? FALSE=8bit */
#define SPEN 1;
#define CREN 1; //Enable Receiver (RX)
#define DIVIDER ((int)(FOSC/(16UL * BAUD) -1))
#define HIGH_SPEED 1
Signal received: DSR Turned ON ...
Data received: <LF>0000%0000<LF>
Data received: <LF>0001%0000<LF>
Data received: <LF>0002%0000<LF>
Data received: <LF>0003%0000<LF>
Data received: <LF>
Data received: 0004%0000<LF>
Data received: <LF>0005
Data received: %0000<LF>
Data received: <LF>0006%0000
Data received: <LF>
Data received: <LF>0007%0000<LF>
Data received: <LF>0008%0000<LF>
Data received: <LF>0009%0000<LF>
Data received: <LF>0010%0000<LF>
Data received: <LF>0011%0000<LF>
Data received: <LF>0012%0000<LF>
Data received: <LF>0013%0000<LF>
Data received: <LF>0014%0000<LF>
Data received: <LF>001
Data received: 5%0000<LF>
Data received: <LF>0016%000
Data received: 0<LF>
Data received: <LF>0017%0000<LF>
Data received: <LF>0018%0000<LF>
Data received: <LF>0019%0000<LF>
Data received: <LF>0020%0000<LF>
Data received: <LF>0021%0000<LF>
Data received: <LF>0022%0000<LF>
Signal received: DSR Turned OFF ...
Nothing is missing here. The problem is just in your way of receiving the data, ignoring any delimiters.but i need it to not miss a single data package and to not take them apart like in the lines:
Data received: <LF>0016%000
Data received: 0<LF>
if ( TimeSlot >= 3 ) TimeSlot = 0 ;
switch ( TimeSlot++ )
{
case 0 : LCD_routines() ; break ;
case 1 : Serial_routines() ; break ;
case 2 : Other_routines() ; break ;
}
char *Receive_MSG(char *String, unsigned short int MSG_Length)
{
unsigned short int Index = 0; // Message Index
while(Index < MSG_Length)
{
String[Index] = getch();
if(String[Index] != 13 && String[Index] != 10)
{
String[Index + 1] = '\0'; // Set the next character to NULL
Index++;
}
else
{
String[Index + 1] = '\0'; // Set the next character to NULL
break;
}
}
return String;
}
void main(void)
{
while(1){
if(RCIF)
{
input = getch(); // read a response from the user
printf("\rI detected [%c]",input); // echo it back
}
lcd_goto(0x48); // Select second line
display_value1(value_dec);
lcd_putch('C');
lcd_goto(0x08);
display_value1(input);
lcd_putch('m');
__delay_ms(100);
value_dec=input-0x30;
You have to remove "string" from "return string". You cant return anything from a void function.
char *s
if(RCIF)
{
input= getch(); // read a response from the user
if(Index !='\0')
{
Index = getch();
*s = Index;
*s++;
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?