CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

uart n lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








uart n lcd
PostPosted: Tue Apr 07, 2009 9:38 pm     Reply with quote

Hai!! all

I want to control red LED at UART hardware. I have to send command to switch on the red LED and display to LCD the return byte.

this is the send command:
Quote:
0xBA,0x03,0x40,0x01,0xB8

and the return byte:
Quote:
0xBD,0x03,0x40,0x00,Checksum

return byte number 4 got two option 0x00 or 0xF0

This is my programming:

Code:
#define (__PCM__)
#include<16f877A.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,parity=n,bits=8)
#include <flex_lcd.c>

unsigned char ControlRedLed[5]       = {0xBA,0x03,0x40,0x01,0xB8};
int8 ctr;
unsigned char rbuff[5];

void main() {
lcd_init();  // Always call this first.

lcd_putc("\fHello World\n");


for (ctr=0;ctr<5;ctr++) putc(ControlRedLed[ctr]); //send command switch on Red LED
for (ctr=0;ctr<5;ctr++) rbuff[ctr]=getc(); //receive 5 response bytes

   if (rbuff[3]==0) {

   lcd_putc("\fon succed\n");// to show LEd able to switch on
   }


   else {

   lcd_putc("\fon fail\n"); // to show fail
   }

for (ctr=0;ctr<5;ctr++){
   lcd_putc(rbuff[ctr]);
   break;
   }

while(1);

}



My result:

The LCD just display Hello world

Red LED at UART hardware also not switch on Crying or Very sad

Plz hep.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 07, 2009 11:27 pm     Reply with quote

Make a simple program that just sends back the bytes that it receives.
This will prove if your basic communication with the host is working.
Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
char c;

while(1)
  {
   c = getc();
   putc(c);
  }


 
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group