mamr_r
- 6th April 2009, 22:15
Good day guys
i m using pic 18f452 for a project to receive a number (for example;003) from matlab. the pic is to receive the number and put it in port d as a binary number. the problem is that it didn't work and i didn't know why;
the matlab code is
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SerPIC = serial('COM1');
set(SerPIC,'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none');
fopen(SerPIC);
fprintf(SerPIC, '%s' ,'003'),
fclose(SerPIC)
delete(SerPIC)
clear SerPIC
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
and the microcode code is
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''
INCLUDE "modedefs.bas"
DEFINE HSER_BAUD 9600
define HSER_CLROERR 1
char var byte
command var byte
loop:
high porta.1
Hserin 20000, loop, [char, dec3 command]
Select Case command
Case 0
portd = 0
Case 1
portd = 1
Case 2
portd = 2
Case 3
portd = 3
CASE ELSE
end Select
Goto loop
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''
could you help me with that
and i ll be very thankful of any suggestions
i m using pic 18f452 for a project to receive a number (for example;003) from matlab. the pic is to receive the number and put it in port d as a binary number. the problem is that it didn't work and i didn't know why;
the matlab code is
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SerPIC = serial('COM1');
set(SerPIC,'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none');
fopen(SerPIC);
fprintf(SerPIC, '%s' ,'003'),
fclose(SerPIC)
delete(SerPIC)
clear SerPIC
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
and the microcode code is
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''
INCLUDE "modedefs.bas"
DEFINE HSER_BAUD 9600
define HSER_CLROERR 1
char var byte
command var byte
loop:
high porta.1
Hserin 20000, loop, [char, dec3 command]
Select Case command
Case 0
portd = 0
Case 1
portd = 1
Case 2
portd = 2
Case 3
portd = 3
CASE ELSE
end Select
Goto loop
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''
could you help me with that
and i ll be very thankful of any suggestions