MY "EMBEDDED C" LEARNING THREAD.......
Sun Mar 20 2011, 01:08 pm
Congrats first of all for winning second prize
Either you're behind a router or your PC is using a firewall. If its a router issue then you need to do port forward so that all incoming connections to router for port configured for HAserver will be forwarded to you local PC.
its used for length of command. maximum length for commands is 4. it was just an informative string. not really an error.
I cannot understand the problem exactly. it maybe anything, not really a problem of device.
1) i connected my project with the "LAN" connection (using 2 pc's)and with one computer itself , then the home automation server get connected....But when i tried using the usual internet connection(or 2 different computers that is not from one LAN connection ), then the server doesnt connected.......so wat is the problem...........?
Either you're behind a router or your PC is using a firewall. If its a router issue then you need to do port forward so that all incoming connections to router for port configured for HAserver will be forwarded to you local PC.
2) wat is the meaning of the word "MAX COUNT REACHED" that is used in this project...........?
its used for length of command. maximum length for commands is 4. it was just an informative string. not really an error.
3) then sometimes i cant type anything in the telnet window...bt when i reset the uc the i can.....so wat is the problem...........?
I cannot understand the problem exactly. it maybe anything, not really a problem of device.
renilraju2050 like this.
Sun Mar 20 2011, 09:02 pm
the basics of c language i hav got from the below sites......(i want it share with people,who really want to study the c programming like me.... )
1)www.learn-c.com
2)www.cprogramming.com/tutorial.html
(and if u know about more sites that hav a good tutorial for "c language" , please share here.....i will be very glad.. )
1)www.learn-c.com
2)www.cprogramming.com/tutorial.html
(and if u know about more sites that hav a good tutorial for "c language" , please share here.....i will be very glad.. )
Mon Mar 21 2011, 10:29 pm
haii all......if anyone know about how to check the program after compiling , please guide me.... .(i mean how to simulate program using keil .....? )
Tue Mar 22 2011, 08:40 am
hey...this is my first c program......please check it and please correct my mistakes.....(here i tried to build a 5 channel LED blinking program.... )
#include <REGX51.H>
sfr p1 =0x90;
sbit pin = p1^0;
sbit pin1 = p1^1;
sbit pin2 = p1^2;
sbit pin3 = p1^3;
sbit pin4 = p1^4;
void main()
{
unsigned char i;
pin = 0xff;
pin1 = 0x00;
pin2 = 0xff;
pin3 = 0x00;
pin4 = 0xff;
while(1)
{
for(i=0;i<20000;i++)
{
pin = ~pin;
pin1 = ~pin1;
pin2 = ~pin2;
pin3 = ~pin3;
pin4 = ~pin4;
}
}
}
#include <REGX51.H>
sfr p1 =0x90;
sbit pin = p1^0;
sbit pin1 = p1^1;
sbit pin2 = p1^2;
sbit pin3 = p1^3;
sbit pin4 = p1^4;
void main()
{
unsigned char i;
pin = 0xff;
pin1 = 0x00;
pin2 = 0xff;
pin3 = 0x00;
pin4 = 0xff;
while(1)
{
for(i=0;i<20000;i++)
{
pin = ~pin;
pin1 = ~pin1;
pin2 = ~pin2;
pin3 = ~pin3;
pin4 = ~pin4;
}
}
}
Tue Mar 22 2011, 09:01 am
reni try this code this will blink 4pins of port1 as what you are trying to do..
or simply like this
#include <REG51.H> sbit pin0 = P1^0; sbit pin1 = P1^1; sbit pin2 = P1^2; sbit pin3 = P1^3; //--------------------------------------- // Delay mS function //--------------------------------------- void delay_ms(unsigned int count) { // mSec Delay 11.0592 Mhz unsigned int i; // Keil v7.5a while(count) { i = 115; while(i> 0) i--; count--; } } void main() { while(1) { pin0 = 0; pin1 = 0; pin2 = 0; pin3 = 0; delay_ms(1000); pin0 = 1; pin1 = 1; pin2 = 1; pin3 = 1; delay_ms(1000); } }
or simply like this
#include <REG51.H> //--------------------------------------- // Delay mS function //--------------------------------------- void delay_ms(unsigned int count) { // mSec Delay 11.0592 Mhz unsigned int i; // Keil v7.5a while(count) { i = 115; while(i> 0) i--; count--; } } void main() { while(1) { P1=0x0f; delay_ms(1000); P1=0x00; delay_ms(1000); } }
[ Edited Tue Mar 22 2011, 09:06 am ]
renilraju2050 like this.
Tue Mar 22 2011, 09:02 am
open proteus select ur ic on which ur working after that drag ans paste that ic
right click on ic it become red now left click on it a new window will come load hex file u want to simulate
see this proteus tutorial
http://www.8051projects.net/forum-t39054.html
right click on ic it become red now left click on it a new window will come load hex file u want to simulate
see this proteus tutorial
http://www.8051projects.net/forum-t39054.html
romel_emperado like this.
Tue Mar 22 2011, 10:14 pm
haii all....this is other program i hav writed in my own...so ifany mistakes is in this , please guide me.......
/*.......This is my first porgram in embedded c................................
.........program for blinking LEDs one by one through port1 pins..................
.........if any mistakes or suggestions is in the program , please guide me.......*/
#include <REG51.H>
sfr p1 = 0x90;
sbit p1_0 = p1^0;
sbit p1_1 = p1^1;
sbit p1_2 = p1^2;
sbit p1_3 = p1^3;
sbit p1_4 = p1^4;
sbit p1_5 = p1^5;
sbit p1_6 = p1^6;
sbit p1_7 = p1^7;
void msdelay(unsigned int);
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void main()
{
while(1)
{
p1_0 = p1_1 = p1_2 = p1_3 = p1_4 = p1_5 = p1_6 = p1_7 = 0x00;
msdelay(10000);
p1_0 = 0xff;
msdelay(10000);
p1_1 = 0xff; p1_0 = 0x00;
msdelay(10000);
p1_2 = 0xff; p1_1 = 0x00;
msdelay(10000);
p1_3 = 0xff; p1_2 = 0x00;
msdelay(10000);
p1_4 = 0xff; p1_3 = 0x00;
msdelay(10000);
p1_5 = 0xff; p1_4 = 0x00;
msdelay(10000);
p1_6 = 0xff; p1_5 = 0x00;
msdelay(10000);
p1_7 = 0xff; p1_6 = 0x00;
msdelay(10000);
}
}
/*.......This is my first porgram in embedded c................................
.........program for blinking LEDs one by one through port1 pins..................
.........if any mistakes or suggestions is in the program , please guide me.......*/
#include <REG51.H>
sfr p1 = 0x90;
sbit p1_0 = p1^0;
sbit p1_1 = p1^1;
sbit p1_2 = p1^2;
sbit p1_3 = p1^3;
sbit p1_4 = p1^4;
sbit p1_5 = p1^5;
sbit p1_6 = p1^6;
sbit p1_7 = p1^7;
void msdelay(unsigned int);
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void main()
{
while(1)
{
p1_0 = p1_1 = p1_2 = p1_3 = p1_4 = p1_5 = p1_6 = p1_7 = 0x00;
msdelay(10000);
p1_0 = 0xff;
msdelay(10000);
p1_1 = 0xff; p1_0 = 0x00;
msdelay(10000);
p1_2 = 0xff; p1_1 = 0x00;
msdelay(10000);
p1_3 = 0xff; p1_2 = 0x00;
msdelay(10000);
p1_4 = 0xff; p1_3 = 0x00;
msdelay(10000);
p1_5 = 0xff; p1_4 = 0x00;
msdelay(10000);
p1_6 = 0xff; p1_5 = 0x00;
msdelay(10000);
p1_7 = 0xff; p1_6 = 0x00;
msdelay(10000);
}
}
Tue Mar 22 2011, 10:24 pm
and this is another program that i hav done in my logic..(i am newer in uc and also in embedded c...so if any mistakes , please forgive me..... )
this program is for running led through port1 pins.........
#include <REG51.H>
sfr port1 = 0x90; /* ==============initialize the port 1============== */
void delay_ms(unsigned char count) /* ==== delay function ==== */
{
unsigned char k;
for(k=0;k>=count;k++); // delay = 1000
}
void main()
{
while(1) /* ==== infinite loop ==== */
{
port1 = 0x00; // port 1 = 00000000
delay_ms(10000); // call delay()
port1 = 0x01; // port 1 = 00000001
delay_ms(1000); // call delay()
port1 = 0x02; // port 1 = 00000010
delay_ms(1000); // call delay()
port1 = 0x04; // port 1 = 00000100
delay_ms(1000); // call delay()
port1 = 0x08; // port 1 = 00001000
delay_ms(1000); // call delay()
port1 = 0x10; // port 1 = 00010000
delay_ms(1000); // call delay()
port1 = 0x20; // port 1 = 00100000
delay_ms(1000); // call delay()
port1 = 0x40; // port 1 = 01000000
delay_ms(1000); // call delay()
port1 = 0x80; // port 1 = 10000000
delay_ms(1000); // call delay()
}
}
this program is for running led through port1 pins.........
#include <REG51.H>
sfr port1 = 0x90; /* ==============initialize the port 1============== */
void delay_ms(unsigned char count) /* ==== delay function ==== */
{
unsigned char k;
for(k=0;k>=count;k++); // delay = 1000
}
void main()
{
while(1) /* ==== infinite loop ==== */
{
port1 = 0x00; // port 1 = 00000000
delay_ms(10000); // call delay()
port1 = 0x01; // port 1 = 00000001
delay_ms(1000); // call delay()
port1 = 0x02; // port 1 = 00000010
delay_ms(1000); // call delay()
port1 = 0x04; // port 1 = 00000100
delay_ms(1000); // call delay()
port1 = 0x08; // port 1 = 00001000
delay_ms(1000); // call delay()
port1 = 0x10; // port 1 = 00010000
delay_ms(1000); // call delay()
port1 = 0x20; // port 1 = 00100000
delay_ms(1000); // call delay()
port1 = 0x40; // port 1 = 01000000
delay_ms(1000); // call delay()
port1 = 0x80; // port 1 = 10000000
delay_ms(1000); // call delay()
}
}
Powered by e107 Forum System