Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

using fwrite instruction in matlab

Status
Not open for further replies.

anasfuad33eng

Member level 1
Member level 1
Joined
Mar 21, 2013
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,498
hi, all when i use these codes in matlab
s=serial('com3','baudrate',9600);
fopen(s)
fwrite(s,00000001,'int8')
8051 receive the value but when display it on led the output 01100000 why this ocurr what is the wrong ?please help:-(
 

org 2000h
mov tmod,#20h
mov th1,#0fah
mov scon,#50h
setb tr1
here:jnb ri,here
mov a,sbuf
mov p1,a
clr ri
sjmp here
end
 

You want to receive data through UART and then assign that data to P1. Right? Why are you using Timer1? You should use Serial Interrupt to receive data from matlab.

try this

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
mov tmod, #20h
mov th1, #-3
mov scon, #50h
setb tr1
clr ri
rpt:    jnb ri, rpt
        mov A, sbuf
        mov P1, A
        end

 
Last edited:

You want to receive data through UART and then assign that data to P1. Right? Why are you using Timer1? You should use Serial Interrupt to receive data from matlab.

try this

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
mov tmod, #20h
mov th1, #-3
mov scon, #50h
setb tr1
clr ri
rpt:    jnb ri, rpt
        mov A, sbuf
        mov P1, A
        end



but sir your code give error at line7 :to0 many operands why?please help
 

Serial_Init:
;Set timer 1 mode to 8-bit Auto-Reload
mov TMOD,#20H
;Enable reception
;Set Serial port mode to 8-bit UART
mov SCON,#50H
;Set baudrate to 9600 at 11.0592MHz
mov TH1,#0FDH
mov TL1,#0FDH
;Start Timer
setb TR1
ret
in this site he move to both th1 and tl1 0fd why??????

- - - Updated - - -

in this site he move to both th1 and tl1 0fd why??????
the program from site
Serial_Init:
;Set timer 1 mode to 8-bit Auto-Reload
mov TMOD,#20H
;Enable reception
;Set Serial port mode to 8-bit UART
mov SCON,#50H
;Set baudrate to 9600 at 11.0592MHz
mov TH1,#0FDH
mov TL1,#0FDH
;Start Timer
setb TR1
ret
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top