SlideShare a Scribd company logo
1 of 8
Download to read offline
C:UsersCARLOSDesktoppractica dspicUART_LEDS.c
#include "p30fxxxx.h" #include "LCD.h" #include "UART.h"
#include "libpic30.h"
//Macros para la configuración de los fusibles
_FOSC(CSW_FSCM_OFF & XT_PLL4); _FWDT(WDT_OFF); _FBORPOR(PBOR_OFF & PWRT_16 & MCLR_EN);
_FGS(CODE_PROT_OFF);
#define BORRAR_HYPERTERMINAL TX_UART1_CHAR('f')
unsigned char rx; void main() {
ADPCFG = 0xFFFF;
__delay_ms(15);
//LCD_CONFIG();
INICIO_UART1(_9600);
//BORRAR_HYPERTERMINAL; //TX_UART1_MENSAJE("Hola alumnos UTPnr",18); //TX_UART1_MENSAJE("ttCuanto va el Peru
Panama?nr",29);
ADPCFG = 0XFFFF;
TRISB = 0xFF00; //Los cuatro pines menos significativos son salida
while(1);
}
void __attribute__((__interrupt__))_U1RXInterrupt(void)
{
rx = U1RXREG;
// if(rx=='s' || rx=='S')
if(rx=='A' ) { PORTBbits.RB0 = 1; __delay_ms(200);PORTBbits.RB0 = 0; __delay_ms(200);}
if(rx=='B' ) { PORTBbits.RB1 = 1; __delay_ms(200);PORTBbits.RB1 = 0; __delay_ms(200); }
// TX_UART1_MENSAJE("Va ganando Peru 2 a 1n",23);
IFS0bits.U1RXIF = 0;
}
// ***********************CONFIGURACION DEL REGISTRO UART***************************
void INICIO_UART1(unsigned char baudios)
{
U1BRG = baudios; //9600 bps, U1BRG es un registro de 16 bits U1MODE = 0; //8 bits de datos, sin paridad(STSEL=0) y 1 bit de
stop.
/*PDSEL<1:0> - Parity and data selection bits 00 – 8-bit data, no parity 01 – 8-bit data, even parity 10 – 8-bit data, odd parity 11 – 9-bit
data, no parity*/
// STSEL – STOP selection bit (STSEL=0 one STOP bit, STSEL=1 two STOP bits)
U1MODEbits.UARTEN = 1; // habilito UART dentro del registro U1MODE
U1STAbits.UTXEN = 1; // habilito la transmision dentro del registro U1STA
IPC2 = IPC2 | 0x0030; // Prioridad nivel 3 para U1RXIP
/* Los registros IECx permite habilitar las respectivas interrupciones del CPU. Una vez puesto a '1' logico el respectivo bit, la
interrupcion queda activa y es posible que un evento la dispare. Estos bits,normalmente se habilitan una sola vez en el programa, a
menos que el programador desee desactivar la interrupcion a raiz de otro evento */
IEC0bits.U1RXIE = 1; // Para habilitar la interrupcion
/* Los registros IFSx contienen las banderas de las diversas interrupciones del DSPIC30F3014. Estas banderas automaticamente se
ponen a '1' logico para indicar que una interrupcion ha ocurrido. Una vez atendida la interrupcion esta bandera debe ser puesta a '0'
logico por firmware, ya que de no hacerlo la rutina de interrupcion sera considerada no atendida por el CPU y esta se volvera a
ejecutar */
IFS0bits.U1RXIF = 0; // Para borrar la bandera o flag de interrupcion por el U1RXREG
}
void TX_UART1_CHAR(unsigned char dato)
{
U1TXREG = dato;
while(U1STAbits.TRMT == 0);
/* TRMT - Transmitir registro de desplazamiento es poco vacío (TRMT = 0 transmiten registro de desplazamiento no está vacío,
transmisión en curso, TRMT = 1 registro de desplazamiento de transmisión está vacía, la transmisión completa) */
}
void TX_UART1_MENSAJE(unsigned char *datos, unsigned char tam)
{
unsigned char i=0;
while(i<tam)
{
TX_UART1_CHAR(datos[i]);
i++;

}
}
C:UsersCARLOSDesktoppractica dspicUART.h
 este archivo incluyan como UART.h
#define _9600 64
#define _19200 32
#define _38400 15
#define _57600 10
void INICIO_UART1(unsigned char baudios);
void TX_UART1_CHAR(unsigned char dato);
void TX_UART1_MENSAJE(unsigned char *datos,unsigned char tam);
void INICIO_UART2(unsigned char baudios);
void TX_UART2_CHAR(unsigned char dato);
void TX_UART2_MENSAJE(unsigned char *datos,unsigned char tam);
EN LA FIGURA SE MUESTRA LA MANERA DE AJUNTAR ESTOS ARCHIVOS “xxx.h” y “xxx.c”
INTERFAZ GUI MATLAB PARA PROBAR LA COMUNICACIÓN SERIAL DSPIC30F3014

function varargout = LEDS(varargin)
% LEDS M-file for LEDS.fig
%
LEDS, by itself, creates a new LEDS or raises the existing
%
singleton*.
%
%
H = LEDS returns the handle to a new LEDS or the handle to
%
the existing singleton*.
%
%
LEDS('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in LEDS.M with the given input arguments.
%
%
LEDS('Property','Value',...) creates a new LEDS or raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before LEDS_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to LEDS_OpeningFcn via varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help LEDS
% Last Modified by GUIDE v2.5 15-Feb-2014 11:26:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LEDS_OpeningFcn, ...
'gui_OutputFcn', @LEDS_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before LEDS is made visible.
function LEDS_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% varargin
command line arguments to LEDS (see VARARGIN)
a=imread('ALF.jpg');
imshow(a);
% Choose default command line output for LEDS
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes LEDS wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = LEDS_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
clear all;
s = serial('COM3');
set(s,'Baudrate',9600);
fopen(s);
fprintf(s,'%s','A');
fclose(s);
delete(s);
clear s

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
clear all;
s = serial('COM3');
set(s,'Baudrate',9600);
fopen(s);
fprintf(s,'%s','B');
fclose(s);
delete(s);
clear s
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

More Related Content

What's hot

Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)yahya ayari
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray EnginePVS-Studio
 
Blood pressure set programming
Blood pressure set programmingBlood pressure set programming
Blood pressure set programmingNoorshahida Kassim
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6fisher.w.y
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
Capture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingCapture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingmartin-pitt
 

What's hot (7)

Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
 
Simware framework hello world: A webinar
Simware framework hello world: A webinarSimware framework hello world: A webinar
Simware framework hello world: A webinar
 
Blood pressure set programming
Blood pressure set programmingBlood pressure set programming
Blood pressure set programming
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
Capture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reportingCapture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reporting
 

Similar to COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15종인 전
 
matlab.code.has.docx
matlab.code.has.docxmatlab.code.has.docx
matlab.code.has.docxssuserfe37cb
 
Antenna Physical Characetristics
Antenna Physical CharacetristicsAntenna Physical Characetristics
Antenna Physical CharacetristicsAssignmentpedia
 
Actividad #7 codigo detección de errores (yango colmenares)
Actividad #7 codigo detección de errores (yango colmenares)Actividad #7 codigo detección de errores (yango colmenares)
Actividad #7 codigo detección de errores (yango colmenares)Yango Alexander Colmenares
 
The following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfThe following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfmarketing413921
 
Embedded systemsproject_2020
Embedded systemsproject_2020Embedded systemsproject_2020
Embedded systemsproject_2020Nikos Mouzakitis
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
 
PLEASE HELP!Modify the source code to implement the followingCh.pdf
PLEASE HELP!Modify the source code to implement the followingCh.pdfPLEASE HELP!Modify the source code to implement the followingCh.pdf
PLEASE HELP!Modify the source code to implement the followingCh.pdfforecastfashions
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - CompilationsHSA Foundation
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLinaro
 
Stability issues of user space
Stability issues of user spaceStability issues of user space
Stability issues of user space晓东 杜
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Vincenzo Iozzo
 
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202Mahmoud Samir Fayed
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreKim Phillips
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisitionazhar557
 

Similar to COMUNICACION SERIAL DSPIC30F3014 Y MATLAB (20)

망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 
matlab.code.has.docx
matlab.code.has.docxmatlab.code.has.docx
matlab.code.has.docx
 
Antenna Physical Characetristics
Antenna Physical CharacetristicsAntenna Physical Characetristics
Antenna Physical Characetristics
 
Actividad #7 codigo detección de errores (yango colmenares)
Actividad #7 codigo detección de errores (yango colmenares)Actividad #7 codigo detección de errores (yango colmenares)
Actividad #7 codigo detección de errores (yango colmenares)
 
The following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfThe following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdf
 
Embedded systemsproject_2020
Embedded systemsproject_2020Embedded systemsproject_2020
Embedded systemsproject_2020
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
PLEASE HELP!Modify the source code to implement the followingCh.pdf
PLEASE HELP!Modify the source code to implement the followingCh.pdfPLEASE HELP!Modify the source code to implement the followingCh.pdf
PLEASE HELP!Modify the source code to implement the followingCh.pdf
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
Gps c
Gps cGps c
Gps c
 
Linux mouse
Linux mouseLinux mouse
Linux mouse
 
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
 
Stability issues of user space
Stability issues of user spaceStability issues of user space
Stability issues of user space
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 

More from Carlos Buitron Quispe

Programación orientada a objetos en vb 2012
Programación orientada a objetos en vb 2012Programación orientada a objetos en vb 2012
Programación orientada a objetos en vb 2012Carlos Buitron Quispe
 
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi techUso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi techCarlos Buitron Quispe
 
Uso del timer0 para el pic 16 f877a con el compilador hi tech
Uso del timer0 para el pic 16 f877a con el compilador hi techUso del timer0 para el pic 16 f877a con el compilador hi tech
Uso del timer0 para el pic 16 f877a con el compilador hi techCarlos Buitron Quispe
 
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENESSISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENESCarlos Buitron Quispe
 
Tutorial de programacion en c para pic16 f877a
Tutorial de programacion en c para pic16 f877aTutorial de programacion en c para pic16 f877a
Tutorial de programacion en c para pic16 f877aCarlos Buitron Quispe
 

More from Carlos Buitron Quispe (6)

Programación orientada a objetos en vb 2012
Programación orientada a objetos en vb 2012Programación orientada a objetos en vb 2012
Programación orientada a objetos en vb 2012
 
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi techUso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
 
Uso del timer0 para el pic 16 f877a con el compilador hi tech
Uso del timer0 para el pic 16 f877a con el compilador hi techUso del timer0 para el pic 16 f877a con el compilador hi tech
Uso del timer0 para el pic 16 f877a con el compilador hi tech
 
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENESSISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
 
Tutorial de programacion en c para pic16 f877a
Tutorial de programacion en c para pic16 f877aTutorial de programacion en c para pic16 f877a
Tutorial de programacion en c para pic16 f877a
 
000191
000191000191
000191
 

COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

  • 1. C:UsersCARLOSDesktoppractica dspicUART_LEDS.c #include "p30fxxxx.h" #include "LCD.h" #include "UART.h" #include "libpic30.h" //Macros para la configuración de los fusibles _FOSC(CSW_FSCM_OFF & XT_PLL4); _FWDT(WDT_OFF); _FBORPOR(PBOR_OFF & PWRT_16 & MCLR_EN); _FGS(CODE_PROT_OFF); #define BORRAR_HYPERTERMINAL TX_UART1_CHAR('f') unsigned char rx; void main() { ADPCFG = 0xFFFF; __delay_ms(15); //LCD_CONFIG(); INICIO_UART1(_9600); //BORRAR_HYPERTERMINAL; //TX_UART1_MENSAJE("Hola alumnos UTPnr",18); //TX_UART1_MENSAJE("ttCuanto va el Peru Panama?nr",29); ADPCFG = 0XFFFF; TRISB = 0xFF00; //Los cuatro pines menos significativos son salida while(1); } void __attribute__((__interrupt__))_U1RXInterrupt(void) { rx = U1RXREG; // if(rx=='s' || rx=='S') if(rx=='A' ) { PORTBbits.RB0 = 1; __delay_ms(200);PORTBbits.RB0 = 0; __delay_ms(200);} if(rx=='B' ) { PORTBbits.RB1 = 1; __delay_ms(200);PORTBbits.RB1 = 0; __delay_ms(200); } // TX_UART1_MENSAJE("Va ganando Peru 2 a 1n",23); IFS0bits.U1RXIF = 0; }
  • 2. // ***********************CONFIGURACION DEL REGISTRO UART*************************** void INICIO_UART1(unsigned char baudios) { U1BRG = baudios; //9600 bps, U1BRG es un registro de 16 bits U1MODE = 0; //8 bits de datos, sin paridad(STSEL=0) y 1 bit de stop. /*PDSEL<1:0> - Parity and data selection bits 00 – 8-bit data, no parity 01 – 8-bit data, even parity 10 – 8-bit data, odd parity 11 – 9-bit data, no parity*/ // STSEL – STOP selection bit (STSEL=0 one STOP bit, STSEL=1 two STOP bits) U1MODEbits.UARTEN = 1; // habilito UART dentro del registro U1MODE U1STAbits.UTXEN = 1; // habilito la transmision dentro del registro U1STA IPC2 = IPC2 | 0x0030; // Prioridad nivel 3 para U1RXIP /* Los registros IECx permite habilitar las respectivas interrupciones del CPU. Una vez puesto a '1' logico el respectivo bit, la interrupcion queda activa y es posible que un evento la dispare. Estos bits,normalmente se habilitan una sola vez en el programa, a menos que el programador desee desactivar la interrupcion a raiz de otro evento */ IEC0bits.U1RXIE = 1; // Para habilitar la interrupcion /* Los registros IFSx contienen las banderas de las diversas interrupciones del DSPIC30F3014. Estas banderas automaticamente se ponen a '1' logico para indicar que una interrupcion ha ocurrido. Una vez atendida la interrupcion esta bandera debe ser puesta a '0' logico por firmware, ya que de no hacerlo la rutina de interrupcion sera considerada no atendida por el CPU y esta se volvera a ejecutar */ IFS0bits.U1RXIF = 0; // Para borrar la bandera o flag de interrupcion por el U1RXREG } void TX_UART1_CHAR(unsigned char dato) { U1TXREG = dato; while(U1STAbits.TRMT == 0); /* TRMT - Transmitir registro de desplazamiento es poco vacío (TRMT = 0 transmiten registro de desplazamiento no está vacío, transmisión en curso, TRMT = 1 registro de desplazamiento de transmisión está vacía, la transmisión completa) */ }
  • 3. void TX_UART1_MENSAJE(unsigned char *datos, unsigned char tam) { unsigned char i=0; while(i<tam) { TX_UART1_CHAR(datos[i]); i++; } } C:UsersCARLOSDesktoppractica dspicUART.h  este archivo incluyan como UART.h #define _9600 64 #define _19200 32 #define _38400 15 #define _57600 10 void INICIO_UART1(unsigned char baudios); void TX_UART1_CHAR(unsigned char dato); void TX_UART1_MENSAJE(unsigned char *datos,unsigned char tam); void INICIO_UART2(unsigned char baudios); void TX_UART2_CHAR(unsigned char dato); void TX_UART2_MENSAJE(unsigned char *datos,unsigned char tam);
  • 4. EN LA FIGURA SE MUESTRA LA MANERA DE AJUNTAR ESTOS ARCHIVOS “xxx.h” y “xxx.c”
  • 5. INTERFAZ GUI MATLAB PARA PROBAR LA COMUNICACIÓN SERIAL DSPIC30F3014 function varargout = LEDS(varargin) % LEDS M-file for LEDS.fig % LEDS, by itself, creates a new LEDS or raises the existing % singleton*. % % H = LEDS returns the handle to a new LEDS or the handle to % the existing singleton*. % % LEDS('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in LEDS.M with the given input arguments. % % LEDS('Property','Value',...) creates a new LEDS or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before LEDS_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to LEDS_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES
  • 6. % Edit the above text to modify the response to help LEDS % Last Modified by GUIDE v2.5 15-Feb-2014 11:26:49 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @LEDS_OpeningFcn, ... 'gui_OutputFcn', @LEDS_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before LEDS is made visible. function LEDS_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to LEDS (see VARARGIN) a=imread('ALF.jpg'); imshow(a); % Choose default command line output for LEDS handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes LEDS wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.
  • 7. function varargout = LEDS_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear all; s = serial('COM3'); set(s,'Baudrate',9600); fopen(s); fprintf(s,'%s','A'); fclose(s); delete(s); clear s % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear all; s = serial('COM3'); set(s,'Baudrate',9600); fopen(s); fprintf(s,'%s','B'); fclose(s); delete(s); clear s