Now, I have made serial connections (RS232) from a microprocessor to this PIC16F877, and I want to send instructions saying initialise the display(above) to the PIC from this microprocessor. These instructions should be sent via the RS232. I want to understand how does the PIC understand my instruction and do this?
Ok, what type of protocol.And how do I write it?
Do I have to use interupts in this case?
Thanks
I understand what you mean. But I cant get to write the control codes and how to call them in case when they are supposed to be used.
Can you give me an example code for this piece..thanks
I don't have time to write code for people, but essentially they are two separate considerations - commands and data.
The normal operating of the device will be data - you send an 'A' and it prints an 'A', you send a 't' it prints a 't' - pretty simple.
Then there are ASCII control data, you send the ASCII symbol for CLR and it clears the screen, you send CR and it scrolls the display and places the cursor on the bottom line. Any of these control codes needs to branch to separate code sections to complete.
Then there is actual LCD commands (assuming you want to go to this level?), you would need to send a specific unused control code, and this would switch the PIC to expect command codes rather than data, and the PIC would switch the LCD to command mode and pass the following data to it. Another control code (or the same one again) could be used to switch the PIC back to normal operation.
Mai g,
Here is a code check it if any prob let me know.You can download whole MikroC files and proteus in code.zip attachment.
#define SWITCH portb.f0
#define ON 1
#define OFF 0
char Buffer[]=" ";
unsigned char BufferCounter=0;
unsigned short i;
void init_oled(void);
void clear_buffer(void);
void main() {
char cmd1[]="ON";
char cmd2[]="OFF";
trisb=0; //to make switch as output bit
Usart_Init(2400);//you can specify your dm355's baud rate
SWITCH=0;
do {
if (Usart_Data_Ready()) { // If data is received
i = Usart_Read(); // Read the received data
Buffer[BufferCounter]=i;
if(strncmp(Buffer,cmd1,2)==0)
{
init_oled();
SWITCH=ON;
clear_buffer();
}
else if(strcmp(Buffer,cmd2)==0)
{
init_oled(); //init oled
SWITCH=OFF;
clear_buffer();
}
else
{
if(++BufferCounter> 2)BufferCounter=0;
}
}
} while (1);
}//~!
void clear_buffer(void)
{
BufferCounter=0;
Buffer[0]=' ';
Buffer[1]=' ';
Buffer[2]=' ';
}
void init_oled(void)
{
//here will be your OLED INIT code
}
you did a small question but its answer is huge? can you pls tell where you are facing problem?.if you like to tell me wht types of displays your company make. so, may be i can guess better about your project
you did a small question but its answer is huge? can you pls tell where you are facing problem?.if you like to tell me wht types of displays your company make. so, may be i can guess better about your project
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?