elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Informática
| |-+  Electrónica
| | |-+  comunicacion rs232 con el pic18f2550
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: comunicacion rs232 con el pic18f2550  (Leído 3,629 veces)
batsy29

Desconectado Desconectado

Mensajes: 2


Ver Perfil
comunicacion rs232 con el pic18f2550
« en: 3 Abril 2010, 01:13 am »

--------------------------------------------------------------------------------
hola a todos  saben tengo un problema quiero crear una interfaz donde pueda leer un numero que venga del puerto rs232 al pic y el pic encienda unos leds pero pasa que le envio el numero con el programa de matlab y trato de leerlo con este mismo programa y me salen puras cosas raras como numeros 255 y 254 y no se porque la verdad es que soy nueva en esto les dejo mi codigo haber si alguien detecta la falla ya que llevo 15 dias y yo no la encuentro auxiliiiioooooo jaja

#include <18F2550.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES XT                       //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL12                    //Divide By 12(48MHz oscillator input)
#FUSES CPUDIV4                  //System Clock by 4
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES VREGEN                   //USB voltage regulator enabled

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


void main()
{
 char d1;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   ////////////////////

set_tris_B(0x01);
output_high(PIN_A0);  // pone el pin a 1
delay_ms (50);
output_low(PIN_A0); // pone el pin a 0      // espera 1 segundo
 
do{
                 

         
        if (kbhit())
        {
           
           d1=getch();
           delay_ms (50); 
           
            putc(d1);
            delay_ms (50); 
           
       // printf("hola estas hay");
        //delay_ms (500);
        output_high(PIN_B0);  // pone el pin a 1
               delay_ms (50);       // espera 1 segundo
               output_low(PIN_B0); // pone el pin a 0
               delay_ms (50);       // espera otro segundo,
        }

     switch( d1 ) {
               
               case '1':       
               output_high(PIN_B0);  // pone el pin a 1
               delay_ms (500);       // espera 1 segundo
               output_low(PIN_B0); // pone el pin a 0
               delay_ms (500);       // espera otro segundo,
          break;
                 
               case '2':

               output_high(PIN_A0);  // pone el pin a 1
               delay_ms (500);       // espera 1 segundo
               output_low(PIN_A0); // pone el pin a 0
               delay_ms (500);       // espera otro segundo,
           }
           

} while (TRUE);        // bucle infinito
   // TODO: USER CODE!!

}


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda con pic18f2550
Electrónica
Fdelilah 0 4,780 Último mensaje 10 Noviembre 2011, 06:43 am
por Fdelilah
Problema con USART en un PIC18F2550
Electrónica
Basu80 2 4,165 Último mensaje 2 Marzo 2013, 14:53 pm
por skapunky
Recibir dos tramas por RS232 diferentes. « 1 2 »
.NET (C#, VB.NET, ASP)
Meta 12 6,234 Último mensaje 29 Noviembre 2023, 23:41 pm
por Meta
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines