Archives
-
Problem Interfacing 16×2 lcs display with at89c51 microcontroller
sir i have interface 16×2 lcd display with microcontroller at89c51 and it is working fine in proteus as well as keil compiler … but when i m burning hex code and interfacing with my hardware i am not able to get the output …. i m posting my coding over here …. please help me out … thanks in advance
#includeltreg51.hgt
#define dp P0
sbit rs=P0^1;
sbit en=P0^2;
sbit rw=P0^3;
lcdcomm(unsigned char val);
lcddat(unsigned char val);
msdelay(unsigned int val);
write_nibble(unsigned int val);unsigned char mydat[]=”hello kaushal”;
unsigned char urdat[]=”hello amit”;main()
{
P0=0xff;
msdelay(10);
lcdint();
lcdcomm(0×01);
msdelay(1);
lcdcomm(0×80);
msdelay(1);
lcddat(‘*’);
msdelay(1);
lcdcomm(0×82);
msdelay(1);
dis_measure();
lcdcomm(0xc2);
msdelay(1);
dis_d_t();
}unsigned char z;
lcdint()
{
rs=0;
rw=0;
dp=0×28;en=1;
msdelay(1);
en=0;
msdelay(1);lcdcomm(0×28);
msdelay(1);lcdcomm(0x0f);
msdelay(1);
}dis_measure()
{
unsigned char z;
for(z=0;zlt=15;z++)
{
lcddat(urdat[z]);
msdelay(1);
}}
dis_d_t()
{
unsigned char z;
for(z=0;zlt=15;z++)
{
lcddat(mydat[z]);
msdelay(1);
}}
/********************************/
lcdcomm(unsigned char val)
{
rs=0;
rw=0;
write_nibble();
}/*****************************/
lcddat(unsigned char val)
{
rs=1;
rw=0;
write_nibble();
}/**************************/
msdelay(unsigned int val)
{
unsigned int i,j;
for(i=0;ilt=val;i++)
for(j=0;jlt=200;j++);
}/************************/
write_nibble(unsigned int val)
{
unsigned char i,j,k;
i=valamp0xf0;
j=dpamp0x0f;
dp=j|i;
en=1;
msdelay(1);
en=0;
msdelay(1);
val=valltlt4;
i=valamp0xf0;
k=dpamp0x0f;
dp=k|i;
en=1;
msdelay(1);
en=0;
msdelay(1);
}Related Forum Messages
- Help needed! PWM speed increases but does not decreses
- Frequency counting
- Microcontroller coin counter with IR sensor
- LCD display of ADC value
- Problem in using the timer 0 for delay in serial interrupt
- PIC18f4550 interface with EEPROM 93c56 using SPI
- Interfacing 89c52 with 25aa080a(SPI) EEPROM
- Problem in my project
- Fatal error in keil c pllzzz solve this
- How can i change the direction of LED light chaser.
- Can not compile LCD code in Keil.
- Interfacing 89c52 with I2C (24c04a)
- Frequency
- RFID BASED AUTO TOLL PLAZA(8051 C program)
- Led display scaning program having some warning in keil
- Humble request…,,,,shall be very thankful.
- RS-485 not separating bytes without external delay
- Embedded code problem in 8051
- Frequency Counter (Using 8051) Calibration
- I/O Confusion
I am trying to make a pwm using 8051. I am using external interrupt 0 (pin 3.1) to increase speed and interrupt 1 (pin 3.2) to decrease speed. My code is working fine for increasing speed but it does not work for decreasing speed. i.e interrupt 1 is not working properly. Code: #include<reg51.h> unsigned char inc = 0; void MSDelay(unsigned int); void ex0_isr (void) interrupt 0 { inc++; // Increment the count } void ex1_isr (void) interrupt 1 { inc=inc--; // Deccrement the count } sbit pwm=P2^0; sbit pwmn=P2^1; sbit enable=P2^2; void universal_delay(unsigned int); void main( ...plz help me modify this code so that it may calculate the frequency of signal for me... CODE: #include ltAT89X51.Hgt // void stepper(unsigned char);//stepper motor void msdelay(unsigned int); void main() { unsigned char value; T1=1; //make t1 an input msdelay(1000); // to count no of pulses in 1 sec TMOD=0x06; //counter 1,mode 2 ,8 bit auto reload mode TH1=0; //set count to ...hi there I m working on coin counter project which can count the no. of coin entering in a boc. I am using at89c51,infrared led and a transistor and lcd for displaying no of counts. LCD display after i make a connection, my LCD show this results. There's no display on it. Im use this code "C Language" #includeltreg51.hgt void lcdcmd (unsigned char value); void lcddata (unsigned char value); void lcdready(); void display(unsigned char z); void MSDelay (unsigned int itime); ...Hi, i have written a small program wherein i change the value on Pot and see the value on the LCD. but m not able to see anything. Please help. the program is as follows. #include ltreg51.hgt sbit rd = P2^5; // for ADC sbit wr = P2^6; // for ADC sbit INTR = P2^7; // for ADC sbit rs = P2^0; // for LCD initilisation sbit rw = P2^1; // for LCD initilisation sbit en = P2^1; // for LCD initilisation sfr ldata = 0x90; //select port 1 for LCD input sfr MYDATA = 0x0B0; //select port 3 for input from ADC void MSDelay(unsigned int itime) { unsigned int i,j; for(i=0;iltitime;i++) for(j=0;jlt1275;j++); } lcdcmd(unsigned char ...The code is below, it run perfectly when i run it step by step during debugging. But when i run it continuously it stuck somewhere after executing the ISR. Is there any mistake i done? please give suggestion if i done any. Thank you. #include <REGX51.H> sbit motof = P2^0; sbit motob = P2^1; void timer2() { TH0 = 0xff; TL0 = 0xfd; TR0 = 1; while(TF0 == 0); ...Hi, I am trying to interface AT93c56 EEPROM to 18F4550.i'm using MCC18 compiler. The EEPROM is wired for x8 configuration. The Problem with it is Every time I read EEPROM it returns 0xff only. My code is as below.. If any one knows the solution plz Help me.. #includeltp18f4550.hgt #includeltspi.hgt #define READ 0xc0 /* 1 10 A8 A7A6A5A4 A3A2A1A0 */ #define EWEN 0x98 /* 1 001 1XXX XXXX */ #define WRITE 0xa0 /* 1 01 A8 A7A6A5A4 A3A2A1A0 */ //#define READ 0x06 /* 1 10 A8 A7A6A5A4 A3A2A1A0 */ //#define EWEN 0x13 /* 1 001 1XXX XXXX */ //#define WRITE 0x05 /* 1 01 A8 A7A6A5A4 A3A2A1A0 */ #define lcd_data PORTD #define RS ...89c52 doesn't have spi, so i written it in software, but doesn't work. this is the code for writing data in to eeprom. please explain how to write it and correct the below code, if there is any error. i am trying to simulate in proteus. CODE: #include ltREGX51.Hgt #include ltintrins.hgt sbit sck = P2^0; sbit swr = P2^1; sbit srd = P2^2; void msdelay(unsigned int ms) { int i,j; for(i=ms;igt0;i--) for(j=122;jgt0;j--); } void write(unsigned int wdata) { int i; for(i=8;igt0;i--) { if((wdataamp0x80)gt0) ...hi , i am trying to interface i2c protocol (da1307,24crom) with 8051 , even though the code is not covered underwhile(1){ } , it gets executed infinetly , wat is the problem , pLZ help me #include ltREGX51.hgt typedef unsigned int uint ; /* i2c function n data */ sfr port = 0x90; sbit scl = P3^7; sbit sda = P3^6; void starti2c(); void stopi2c(); void rominit(); void i2cwrite(uint); void i2cread(); void mdelay(); bdata uint data1; sbit msb = data1^7; sbit lsb = data1^0; /*lcd-----------------------*/ sbit en = P3^4; sbit rs = P3^5; void lcdinit(); void lcddata(unsigned int); void lcddatachar(unsigned char *); void lcdcmd(unsigned char); void bcdtoascii(unsigned int ); void msdelay(uint ); //-------------------------------- idata uint romwrite = 0xA0; idata uint romread = 0xA1; idata uint testdata = ...Build target 'Target 1' assembling STARTUP.A51... compiling Text1.c... TEXT1.C(1): warning C500: SERIAL NUMBER EXPIRED linking... BL51 BANKED LINKER/LOCATER V6.11 - SN: K1M9C-X6TNMH COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2007 "STARTUP.obj", "Text1.obj" TO "delay" RAMSIZE(256) *** FATAL ERROR L210: I/O ERROR ON INPUT FILE: EXCEPTION 0021H: PATH OR FILE NOT FOUND FILE: Text1.obj Target not created why this type of eror so my code is CODE: #includeltREG51.hgt void msdelay(unsigned int); void main(void) { while(1) { P1=0x0f; msdelay(1000); P1=0x01; msdelay(1000); P1=0x02; msdelay(1000); P1=0x04; msdelay(1000); P1=0x08; msdelay(1000); } } void msdelay(unsigned int x) { unsigned int i,j; for(i=0;iltx;i++) for(j=0;jlt922;j++); }i want to assemble light chaser with basic function (change the direction of LED chaser, RgtL, LgtR).i put the three LED with port 1(P1.0,P1.1,P1.2). Two micro switch with port 3(P3.0, P3.1, P3.0 for RgtL , P3.1 for LgtR) for change the direction of LED chaser .The problem which i facing, i cannot able to understand how can i change the value in loop.Plz someone correct this coding. CODE: #includeltatmel\at89x51.hgt // void MSDelay(unsigned int); void rl(); void lr(); sbit led1 = P1^0 ; sbit led2 = P1^1 ; sbit led3 = P1^2 ; sbit b1 = P3^0; sbit b2 = P3^1; int a; void main(void) { ...I saw this code in the book and i want to try it out but keil is giving me warnings...plz suggest me to solve the problem here is the code:- #include ltreg51.hgt sfr ldata = 0x90; sbit rs = P2^0; sbit rw = P2^1; sbit en = P2^2; sbit busy = P1^7; void main() { lcdcmd(0x38); lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x86); lcddata('M'); lcddata('D'); lcddata('E'); } void lcdcmd(unsigned char value) { lcdready(); ldata = value; rs = 0; rw = 0; en = 1; MSDelay(1); en = 0; return; } void lcddata(unsigned char value) { lcdready(); ldata=value; rs = 1; rw = 0; en = 1; MSDelay(1); en = 0; return; } void lcdready() { busy = 1; rs = 0; rw = 1; while(busy==1) { en = 0; MSDelay(1); en = 1; } return; } void MSDelay(unsigned int itime) { unsigned char i,j; for(i=0;iltitime;i++) for(j=0;jlt=1275;j++); } and i am getting these errors :- Build target 'Target 1' compiling lcd.c... lcd.c(9): warning C206: ...The example code using keil and simulated using proteus CODE: #includeltregx51.hgt #includeltintrins.hgt sbit scl = P2^0; sbit sda = P2^1; void msdelay(unsigned char ms) { int i,j; for(i=0;ilt=ms;i++) for(j=0;jlt=6000;j++); } void sta() { sda = 1; scl = 1; _nop_(); sda = 0; _nop_(); scl = 0; } void stop() { sda = 0; scl = 1; msdelay(15); sda = 1; msdelay(10); } void ack() { sda = 1; scl = 1; F0 = 0; if(sda == 0) F0 = 1; scl = 0; _nop_(); } void mack() { sda = 0; scl = 1; _nop_(); scl = 0; } void mnack() { sda = 1; scl = 1; _nop_(); scl = 0; } char rdata() { unsigned char nn=0xff,mm=0x80,uu=0x7f; char j; sda=1; for(j=0;jlt8;j++) ...hey ajay as you told me the method how to calculate coming unknown fequency using 8051 counter by starting timer , giving one second delay and then stoppping the timer simply take a look at the code below i have tried but it is not working ok in proteus #include ltAT89X51.Hgt void msdelay(unsigned int); void main() { T1=1; //make T1 an Input TMOD=0x06; //counter 1 mode2 8 bit auto reload mode TH1=0; //set count to 0 TR1=1; //start timer msdelay(1000); //1 second delay TR1=0; //stop timer P1=TL1; //place value on port1 } void msdelay(unsigned int itime) // for msdelay { unsigned int i,j; for(i=0;iltitime;i++) for(j=0;jlt1275;j++); } plz help me modify this code so that it approprately calculates the coming unknown ...Respected Sir/Maam; I am working on 8051.We are doing programming in 8051 C.I am having a doubt related to STEPPER motor.Our project is on RFID BASED AUTO TOLL PLAZA.This is the program that I have written for forward motion and reverse of stepper motor.Will you please help me whether this program is correct or not and also to stop the motor at a particular instant what changes I need to make in this. #includeltreg51.hgt #define ld P1 #define stepper P2 sbit obj = P3^1; sbit led = P3^2; void msdelay(unsigned int); void delay(unsigned int); void UP(); void DOWN(); void main() { unsigned char j,k; ld = 0xFF; obj = 1; while(1) { //unsigned char m1[]= "WELCOME"; //unsigned char ...#include ltREGX51.Hgt void msdelay(unsigned int); vid(clock); void set(); void dispaly(unsigned char); void msdelay(unsigned int itime) { unsigned int i,j; for(i=0; iltitime; i++) { for(j=0; jlt100; j++) { } } } void clock () { P1_0 = 1; P1_0 = 0; } void display(unsigned char c) { P0 = c; msdelay(1); // clock(); } void set() { P1_1 = 0; P1_1 = 1; } void main(void) { void set(); P0 = 0x00; P1 = 0x00; display(0x88); display(0x94); display(0x02); display(0x01); display(0x01); display(0x81); display(0x58); display(0x10); set(); } when i run the above program the keil shows some warning what is that Build target 'Target 1' compiling ledstil.c... linking... *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?CLOCK?LEDSTIL Program Size: data=9.0 xdata=0 code=114 creating hex file from "ledstiill"... "ledstiill" - 0 Error(s), 1 Warning(s). please help meHow to calculate frequency of square wave with unknown frquency coming on P3.5 of 8051 controller in c? my effort is as follows.plz help by modifying it. i am not sure ,will the following program keep on counting or will calculate the pulses in one second..? #include ltAT89X51.Hgt void msdelay(unsigned int); void main() { unsigned char value; T1=1; //make t1 an input TMOD=0x06; //counter 1,mode 2 ,8 bit auto reload mode TH1=0; //set count to 0 while(1) //repeat forever { do { TR1=1; //start timer value=TL1; //store tL1 in value P1=value; //place value on pins of p1 } while(TF1==0); //wait here TR1=0; //stop timer TF1=0; //clear flag } } void msdelay(unsigned int itime) { unsigned int i,j; for(i=0;iltitime;i++) for(j=0;jlt1275;j++); }I am using a BL2600 Single-board computer and am having trouble with the RS-485. I have a simple program that uses RS-485 to send a command to another device (just transmitting, no receiving on this side). However, when I run it, it sends the data too fast, despite me setting the baud rate. I have to add 1 ms delays between the bytes to actually keep them separate. Here is my code: #class auto #define EINBUFSIZE 255 #define EOUTBUFSIZE 255 nodebug //?? void msDelay(unsigned int delay) { auto unsigned long done_time; done_time = MS_TIMER + delay; while( (long) (MS_TIMER - done_time) lt 0 ); } void main() { char highb, lowb; brdInit(); serEopen(38400); serEwrFlush(); serErdFlush(); serMode(1); for(;;) { //G2P60 if(!digIn(0)) { highb=0x13; lowb=0x88; } else if(!digIn(1)) { highb=0x27; lowb=0x10; } else if(!digIn(2)) { highb=0x3A; lowb=0x98; } else if(!digIn(3)) { highb=0x4E; lowb=0x20; } else { highb=0; lowb=0; } ser485Tx(); serEputc(0x00); msDelay(1); serEputc(0x02); msDelay(1); serEputc(60); msDelay(1); serEputc(highb); msDelay(1); serEputc(lowb); msDelay(1); ser485Rx(); } } Without ...Hiiiiiiii friends i am new to 8051 microcontroller. I have just made a simple code for my practice,but i got an error that is (*** error 65: access violation at C:0x0A00 : no 'execute/read' permission) program show no error at the time of building but at time of debugging compiler shows this error . when i made a modification in the program and remove for loop and in place of for loop apply infinite while its running successfully,so Is the problem in for loop? Here is my code Code: #include <reg51.h> void MSDelay(unsigned int); sbit Dsensor=P1^1; sbit Buzzer=P1^7; void main(void) { unsigned int c; EA=0; Buzzer=1; TMOD =0X01 ; TL0=0X00; TH0=0X00; c=0; for(c=0;c<10;c++) { TR0=1; while (TF0==0); TR0=0; TF0=0; MSDelay(200); ...Hello I am having a problem in Calibrating the Frequency Counter. I've used Counter 0 16-bit mode. And I am actually recording values in TL0 and TH0 as the counter is run as then they are refreshed. The problem is that TL0 and TH0 gives the values in HEX, and I am not able to implement a formula to calibrate the value, since I cannot multiply or divide the HEX values that I get from the TL0 and TH0. Please advise me some technique in C-programming on how can I "combine" TH0 and TL0 values to get values in a single variable then how can ...I'm trying to attach an LCD (HD44780) to the aux Data Bus and I'm not having much luck. This is the first time I've ever written code from scratch on the RCM3000. I've always maintain existing code so I have learn a bit.. I have EN tied to I6 and PG4 tied to R/S. I can't see I6 change at all (but I can see the data in the bus) I must have messed up in the software somewhere. WrPortI(PEDDR, ampPEDDRShadow, 0xFF); //set bits 7,6,5,4,3,2,1,0 to output WrPortI(PEFR, ampPEFRShadow, 0xFF); // Set all of Port E to Strobes WrPortI(PEDR, ampPEDRShadow, 0xFF); //brdInit(); WrPortI(IB6CR, ampIB6CRShadow, 0x68); // I6 is ...
