free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  1 2 3 ... 18 [19] 20 ... 26 27 28
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
ExperimenterUK
Mon Nov 17 2008, 11:25AM
 User Online
Registered Member #9602
Joined: Tue Aug 05 2008, 04:15PM

Posts: 207
Thanked 38 times in 37 posts
ExperimenterUK wrote ...

sks wrote ...

Hello Mr Arun,
i hv checked the code modified by you. either i don't understand the code or may be sum bugs are there. i hv rewrite the blinker again using timer flag, please check and comment.
thanks all
sks

@sks
In your " Tue Nov 11 2008, 04:21AM" post, did you intend to use an interrupt to
service the timer overflow ?


@sks
I asked about the interrupt because in the code you posted there are references to
an interrupt routine. (;timer0 isr and reti)
Arun assumed you were using an interrupt routine and was trying to make it work.
That is why Arun's post did not make sense to you.





Learning all the time
Back to top



This post has been thanked 1 time
 sks 
sks
Tue Nov 18 2008, 01:58AM
 User Offline
Registered Member #9477
Joined: Thu Jul 31 2008, 07:51AM

Posts: 160
Thanked 0 times in 0 posts
Hello Mr ExperimenterUK,
thanks fr the post. In your " Tue Nov 11 2008, 04:21AM" post, did you intend to use an interrupt to service the timer overflow ?" the answer is NO i was trying to write the code using Timer to blink a LED, that is it. as u know i hv never used timer before, that's a mistake. pl check the posted code on "Wed Nov 12 2008, 10:34PM" and comment, i know Mr Arun is busy fr a week or so.
thanks all
sks

Back to top


sks
Wed Nov 19 2008, 12:00AM
 User Offline
Registered Member #9477
Joined: Thu Jul 31 2008, 07:51AM

Posts: 160
Thanked 0 times in 0 posts
Hi all,
i hv written a code to communicate between PC and 8051 using Hyper Terminal. i m facing some problem like (1) i don't see my data string which is inside 8051 in Terminal window. (2) if i type A in my PC Keyboard i am getting a data in 8051 Port1 using 8 LEDs, but i couldn't recognize what type of data is that. is it in ASCII, HEX or what? please help me by clarifying.
thanks all
sks
CODE:
;8051 Serial communication using Hyper Terminal
;Received Data from PC is to be Displayed in Port_1
;Send data from 8051 is to be displayed in HyperTerminal
;Baud rate is 4800

        ORG     0000H
        MOV     P2,#0FFH        ;Make p2 as input port
        MOV     TMOD,#20H       ;Timer1 in Mode2 Auto Reload
        MOV     TH1,#0FAH       ;Baud rate is 4800
        MOV     SCON,#50H       ;8_Bit Data,1_Stop Bit
        SETB    TR1             ;Start Timer1
        MOV     DPTR,#MESSAGE    ;Load Pointer for Message
MAIN_1:
        CLR     A               ;Clera Accumulator
        MOVC    A,@A+DPTR       ;Load Data in Accumulator
        JZ      MAIN_2          ;Jump to Main_2 if data is zero
        CALL    SEND            ;Send data to PC
        INC     DPTR
        SJMP    MAIN_1
MAIN_2:
        MOV     A,P2            ;Load input data from Port2 in Accu
        CALL    SEND            ;Send data to PC
        CALL    RECV
        MOV     P1,A            ;Load Accu Data in P1
        SJMP    MAIN_2
SEND:
        MOV     SBUF,A
WAIT:
        JNB     TI,WAIT         ;Wait till data send is completed
        CLR     TI
        RET
RECV:
        JNB     RI,RECV
        MOV     A,SBUF
        CLR     RI
        RET
MESSAGE:
Db 'COMMUNICATIN TERMINAL IS READY'
        END
 


[ Edited Wed Nov 19 2008, 10:03AM ]

Back to top


pdi33
Wed Nov 19 2008, 05:32AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 773
Thanked 186 times in 181 posts
hi sks,
ur doubt is quite valid. All communication from/to the PC uses ASCII system for communication. So the data u received from the PC is ASCII and u have to convert it to decimal first for processing. As for the sending is concerned, the data u defined is already in ASCII so it should logically be seen on the hyperterminal, so there seem to be some error in communication.possible reasons could be:
1.u have not set the hyperterminal setting to 4800 baud
2. what is the crystal frequency u have chosen in ur hardware? 12mHz. or 11.059Mhz.
3. check if uhave connected the Rx of 8051 to Tx of PC and vice versa through the MAX232.

Also add 00 at the end of ur message for proper termination as according to ur logic, the loop continues sending the message string until it encounters 0.

DB ' your message',0

[ Edited Wed Nov 19 2008, 05:36AM ]

* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 sks 
sks
Wed Nov 19 2008, 07:45AM
 User Offline
Registered Member #9477
Joined: Thu Jul 31 2008, 07:51AM

Posts: 160
Thanked 0 times in 0 posts
Hello pdi,
thank u very much for clearing my doubt. my hyper terminal baud rate setting is 4800. i m using 11.0592mhz crystal in my kit and one thing i hv to check the cable for TX to RX and RX to TX part and let u know tomorrow. also i will correct the code as advised by u. one more thing i will like to know for ASCII to DEC Conversion is 30 common factor?.
thanks again
sks

Back to top


pdi33
Wed Nov 19 2008, 07:07PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 773
Thanked 186 times in 181 posts
as long as the value is numerical (0 to 9), then adding 30h is sufficient. Note that while outputting a byte of data, first u have to split it into two nibbles, convert them in ascii and then output them to the PC.


* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 sks 
sks
Thu Nov 20 2008, 12:46AM
 User Offline
Registered Member #9477
Joined: Thu Jul 31 2008, 07:51AM

Posts: 160
Thanked 0 times in 0 posts
Hello pdi,
Thanks for the reply. i have doubts regarding Hyper Terminal & ASCII Codes. i am using NSK 8051 kit having MAX232 built in, and using a complete PARALLEL cable, the same cable is used in my ISP. The cable is working alright in ISP. Also i have done a schematic in Proteus like in my kit. when i simulate using same code in Proteus the 8 LEDs in Port1 shows different values not like in my kit. here is the fresh code, it's for just to receive data from PC. Also i m attaching the schematic. some of the showing values in my kit are also here fr ur study. please help me by clarifying my doubts. i am sorry for a lengthy post.
thanks all
sks
;Receive Byte of Data Serially From PC & put them
;in Port1 of 8051
;Baud 4800,8_bit,1stop_bit

ORG 0000H
MOV TMOD,#20H ;Timer1 in Mode2 (AutoReload)
MOV TH1,#0FAH ;Baud rate 4800
MOV SCON,#50H ;8_Bit,1_Stop_Bit,REN Enabled
SETB TR1 ;Start Timer1
HERE:
JNB RI,HERE ;Stay here till a byte is received
MOV A,SBUF ;Load received byte in Accu
MOV P1,A ;Load data in Port1
CLR RI ;Get ready for next Byte
SJMP HERE
END
The showing Values in my Kit are like
0=06,1=67,2=33,3=66,4=19,5=65,6=32,7=64,8=0C,A=5F,B=2F,C=5E,D=17,a=4f,b=27,c=4e so on



Back to top


pdi33
Thu Nov 20 2008, 04:09AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 773
Thanked 186 times in 181 posts
hi sks,
ur code seems fine and should work. I have simulated ur code in the proteus ckt u have posted and it works just as fine.So i think there seems to be some conflict in the hyperterminal setting.
Try using this terminal software ( very good one!!) and check again. be sure to set baud rate,8N1 and flow control to 'none'. As ur kit is using the sae UART pins for entering ISP mode, there might be some conflict in thecontrol lines used in the serial port ( DTR/CTS). So be sure to keep the flow control to none.
http://www.8051projects.net/downloads112.html

[ Edited Thu Nov 20 2008, 04:12AM ]

* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 sks 
sks
Thu Nov 20 2008, 04:40AM
 User Offline
Registered Member #9477
Joined: Thu Jul 31 2008, 07:51AM

Posts: 160
Thanked 0 times in 0 posts
Hi pdi,
thanks. i think the settings what u hav suggested is already there. 8N1 u mean
8_bit, parity NONE, 1 stop_bit i think. it is there. my ISP is another DEVICE. i am not using my NSK kit for flashing/programming, it just for testing codes and running programs. Any way i will check everything thoroughly and let u know tomorrow. one thing pl let me know in Proteus the values are showing like 0=01110000,1=01110001,A=10000001,B=10000010,a=11100001 and so on. what it means? pl give me a clue.
thanks
sks

Back to top


pdi33
Thu Nov 20 2008, 06:43AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 773
Thanked 186 times in 181 posts
yep,
i too got the same readings initially and they are wrong. The mistake i did in the simulation was keeping the crystal frequency to 12Mhz. Note that proteus does not take on the crystal frequency connected to XTAL . It works just fine even when u do not connect the crystal in te circuit at all just like the RST and EA/Vpp pins. The main frequency used for the simulation should be set in the properties window of the uC which is by default 12Mhz. So if u change that to 11.0592Mhz, u will get the true ASCII output on the LEDs(verified).
0 -> 0011 0000 -> ASCII 30h
1 -> 0011 0001 -> ASCII 31h
A -> 0100 0001 -> ASCII 41h
... and so on.
do take care of the flow control.
good luck.



* inspired to develop,developing to inspire *
Back to top



This post has been thanked 1 time
 sks 
Go to page  1 2 3 ... 18 [19] 20 ... 26 27 28  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems