Autor Tema: Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.  (Leído 3629 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado alexiel

  • PIC10
  • *
  • Mensajes: 31
Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.
« en: 08 de Marzo de 2010, 21:01:15 »
Hola señores del foro.
Les relato un problema que tengo para ver si le ha ocurrido a alguien o si alguien sabe, por favor me lo haga saber.
He trabajado con el UART1 del dspic33fj64gp802, con el Rp10 como Tx y Rp11 como Rx y ha trabajado correctamente el UART.
Por motivos de diseño en la PCB me tocó hacer un cambio (para hacer un mejor enrutado), pasé el Rx al Rp15 y el Tx al Rp14.
Como había probado ya la comunicación UART, pensé que sería lo mismo con los Rp15 y Rp14. Cuando terminé de hacer la PCB y comienzo a utilizar el UART1 (ya habiendole hecho los cambios en el sotfware, pasar Rp15 como Tx y Rp14 como Rx), me llevo gran sorpresa solo servía la transmision Tx y la recepcion NO :5]. Empecé nuevamente a hacer pruebas en una protoboard. Las pruebas que hice fue invertir los Rpn, el Rp15 ahora como Rx y Rp14 como Tx y sucedía lo mismo, solo servía la transmision. Como sé que sirve el UART con los Rp10 y Rp11, hice una combinación, tomé el Rp10 como Rx y Rp15 como Tx y funcionó correctamente, cuando los intercambié, Rp15 como Rx y Rp14 como Tx, solo transmitía... Que problema, además he mirado en la datasheet y no he encontrado que solo algún remapable funcione de salida y no de entrada. Si alguno de los del foro ha leido en alguna parte sobre el problema con estos remapables que coloquen el link para informarnos sobre los problemillas como éstos. También he leido las erratas de este dspic pero sobre esto no dice nada todavía. Aparte de la erratas en microchip donde se puede informar sobre problemas como estos o como los busca uno.. Gracias de ante mano a todos por su colaboracion.

Desconectado alexiel

  • PIC10
  • *
  • Mensajes: 31
Re: Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.
« Respuesta #1 en: 11 de Marzo de 2010, 18:05:56 »
Hola a todos...
Ahora hice pruebas con los pines Rp13 y Rp12, poniendolos como RX del UART y tampoco funciona..Solo me ha funcionado con el Rp11 y Rp10. Seguiré probando con los demás Rpn´s.

micronoob

  • Visitante
Re: Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.
« Respuesta #2 en: 11 de Marzo de 2010, 18:40:49 »
hola,

esto es un hardware PPS puedes poner tu código de configuración?

tengo una librería para configurar el pps de forma automática es para 24F pero en un segundo te lo puedo remapar para tu dsp

saludos.

micronoob

  • Visitante
Re: Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.
« Respuesta #3 en: 11 de Marzo de 2010, 22:31:53 »
hola ,

ok mira te dejo el código para los métodos rápidos o mejor dicho macros de asociar una función hardware a unos pines PPS

deberás solo mapear tus pines

y se usa asi

                             RX  TX
      SetUART1wpps(RP0,RP1);   y ya tienes la uart sobre los rp que quieres


Código: [Seleccionar]
/*¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
 ¦¦__________________[RTOSys PPS for PIC24F  ]_____________________
  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
 ¦¦
 ¦¦     FileName:      OSpps24F.h
 ¦¦ Dependencies:      ...
 ¦¦    Processor:      MCU PIC24FJ64GA004
 ¦¦     Compiler:      C30
 ¦¦     Hardware:      Generic
 ¦¦
 ¦¦      Company:     RTOSys project group
 ¦¦    OSCompany:     RTOSys project group
 ¦¦
 ¦¦ Software License Agreement: 
 ¦¦ 
 ¦¦                    - Limited Use -
 ¦¦
 ¦¦¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
 ¦¦ Author           ¦  Date            ¦ Comment
 ¦¦¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¦¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¦¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
 ¦¦ Maurizio Spoto   ¦ 10-06-2008       ¦ Start Project
 ¦¦                  ¦                  ¦
 ¦¦_______________________________________________________________
  ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
 
  #define _PPS_P24FJ64GA004_
 
 
  typedef enum _PPS_INPUT
  {
  INULL = (0u), 
  FINT1,
  FINT2,
  FINT3,
  FINT4,
  FT2CK,
  FT3CK,
  FT4CK,
  FT5CK,
  FIC1,
  FIC2,
  FIC3,
  FIC4,
  FIC5,
  FOCFA,
  FOCFB,
  FU1RX,
  FU1CTS,
  FU2RX,
  FU2CTS,
  FSDI1,
  FSCK1,
  FSS1,
  FSDI2,
  FSCK2,
  FSS2
 
 }ppsInputFunction; 

  typedef enum _PPS_OUTPUT
  {
  ONULL = (0u), 
  FC1OUT,
  FC2OUT,
  FU1TX,
  FU1RTS,
  FU2TX,
  FU2RTS,
  FSDO1,
  FSCK1OUT,
  FSS1OUT,
  FSDO2,
  FSCK2OUT,
  FSS2OUT,
  FOC1 = (18u),
  FOC2,
  FOC3,
  FOC4,
  FOC5
 
 }ppsOutputFunction; 
 
 
 typedef enum _PPS_PIN
 {  
     RP0 = (0u),
     RP1 ,RP2 ,RP3 ,RP4 ,RP5 ,
RP6 ,RP7 ,RP8 ,RP9 ,RP10,
RP11,RP12,RP13,RP14,RP15,
RP16,RP17,RP18,RP19,RP20,
RP21,RP22,RP23,RP24,RP25

 }ppsPin; 
 
 //BIT INDEX FUNCTION TO PPS INPUT REG
 #define IINT1         RPINR0bits.INT1R
 #define IINT2         RPINR1bits.INT2R
 #define IINT3         RPINR1bits.INT3R
 #define IINT4         RPINR2bits.INT4R
 #define IT2CK         RPINR3bits.T2CKR
 #define IT3CK         RPINR3bits.T3CKR
 #define IT4CK         RPINR4bits.T4CKR
 #define IT5CK         RPINR4bits.T5CKR
 #define IIC1          RPINR7bits.IC1R
 #define IIC2          RPINR7bits.IC2R
 #define IIC3          RPINR8bits.IC3R
 #define IIC4          RPINR8bits.IC4R
 #define IIC5          RPINR9bits.IC5R
 #define IOCFA         RPINR11bits.OCFAR
 #define IOCFB         RPINR11bits.OCFBR
 #define IU1RX         RPINR18bits.U1RXR
 #define IU1CTS        RPINR18bits.U1CTSR
 #define IU2RX         RPINR19bits.U2RXR
 #define IU2CTS        RPINR19bits.U2CTSR
 #define ISDI1         RPINR20bits.SDI1R
 #define ISCK1         RPINR20bits.SCK1R
 #define ISS1          RPINR21bits.SS1
 #define ISDI2         RPINR22bits.SDI2R
 #define ISCK2         RPINR22bits.SCK2R
 #define ISS2          RPINR23bits.SS2
 
 //BIT OUTPUT
 #define ORP0           RPOR0bits.RP0R
 #define ORP1           RPOR0bits.RP1R
 #define ORP2           RPOR1bits.RP2R
 #define ORP3           RPOR1bits.RP3R
 #define ORP4           RPOR2bits.RP4R
 #define ORP5           RPOR2bits.RP5R
 #define ORP6           RPOR3bits.RP6R
 #define ORP7           RPOR3bits.RP7R
 #define ORP8           RPOR4bits.RP8R
 #define ORP9           RPOR4bits.RP9R
 #define ORP10          RPOR5bits.RP10R
 #define ORP11          RPOR5bits.RP11R
 #define ORP12          RPOR6bits.RP12R
 #define ORP13          RPOR6bits.RP13R
 #define ORP14          RPOR7bits.RP14R
 #define ORP15          RPOR7bits.RP15R
 #define ORP16          RPOR8bits.RP16R
 #define ORP17          RPOR8bits.RP17R
 #define ORP18          RPOR9bits.RP18R
 #define ORP19          RPOR9bits.RP19R
 #define ORP20          RPOR10bits.RP20R
 #define ORP21          RPOR10bits.RP21R
 #define ORP22          RPOR11bits.RP22R
 #define ORP23          RPOR11bits.RP23R
 #define ORP24          RPOR12bits.RP24R
 #define ORP25          RPOR12bits.RP25R
 
 #if defined(_PPS_P24FJ64GA004_)
 
    //RP0
    #define PRP0_TRIS   (TRISBbits.TRISB0)
    #define PRP0_WR_IO  (LATBbits.LATB0)
    #define PRP0_RD_IO  (PORTBbits.RB0)
    //RP1
    #define PRP1_TRIS   (TRISBbits.TRISB1)
    #define PRP1_WR_IO  (LATBbits.LATB1)
    #define PRP1_RD_IO  (PORTBbits.RB1)
    //RP2
    #define PRP2_TRIS   (TRISBbits.TRISB2)
    #define PRP2_WR_IO  (LATBbits.LATB2)
    #define PRP2_RD_IO  (PORTBbits.RB2)   
    //RP3
    #define PRP3_TRIS   (TRISBbits.TRISB3)
    #define PRP3_WR_IO  (LATBbits.LATB3)
    #define PRP3_RD_IO  (PORTBbits.RB3)
    //RP4
    #define PRP4_TRIS   (TRISBbits.TRISB4)
    #define PRP4_WR_IO  (LATBbits.LATB4)
    #define PRP4_RD_IO  (PORTBbits.RB4)
    //RP5
    #define PRP5_TRIS   (TRISBbits.TRISB5)
    #define PRP5_WR_IO  (LATBbits.LATB5)
    #define PRP5_RD_IO  (PORTBbits.RB5)
    //RP6
    #define PRP6_TRIS   (TRISBbits.TRISB6)
    #define PRP6_WR_IO  (LATBbits.LATB6)
    #define PRP6_RD_IO  (PORTBbits.RB6)
    //RP7
    #define PRP7_TRIS   (TRISBbits.TRISB7)
    #define PRP7_WR_IO  (LATBbits.LATB7)
    #define PRP7_RD_IO  (PORTBbits.RB7)
    //RP8
    #define PRP8_TRIS   (TRISBbits.TRISB8)
    #define PRP8_WR_IO  (LATBbits.LATB8)
    #define PRP8_RD_IO  (PORTBbits.RB8)
    //RP9
    #define PRP9_TRIS   (TRISBbits.TRISB9)
    #define PRP9_WR_IO  (LATBbits.LATB9)
    #define PRP9_RD_IO  (PORTBbits.RB9)
    //RP10
    #define PRP10_TRIS   (TRISBbits.TRISB10)
    #define PRP10_WR_IO  (LATBbits.LATB10)
    #define PRP10_RD_IO  (PORTBbits.RB10)
    //RP11
    #define PRP11_TRIS   (TRISBbits.TRISB11)
    #define PRP11_WR_IO  (LATBbits.LATB11)
    #define PRP11_RD_IO  (PORTBbits.RB11)
    //RP12
    #define PRP12_TRIS   (TRISBbits.TRISB12)
    #define PRP12_WR_IO  (LATBbits.LATB12)
    #define PRP12_RD_IO  (PORTBbits.RB12)
    //RP13
    #define PRP13_TRIS   (TRISBbits.TRISB13)
    #define PRP13_WR_IO  (LATBbits.LATB14)
    #define PRP13_RD_IO  (PORTBbits.RB15)
    //RP14
    #define PRP14_TRIS   (TRISBbits.TRISB14)
    #define PRP14_WR_IO  (LATBbits.LATB14)
    #define PRP14_RD_IO  (PORTBbits.RB14)
    //RP15
    #define PRP15_TRIS   (TRISBbits.TRISB15)
    #define PRP15_WR_IO  (LATBbits.LATB15)
    #define PRP15_RD_IO  (PORTBbits.RB15)
    //RP16
    #define PRP16_TRIS   (TRISCbits.TRISC0)
    #define PRP16_WR_IO  (LATCbits.LATC0)
    #define PRP16_RD_IO  (PORTCbits.RC0)
    //RP17
    #define PRP17_TRIS   (TRISCbits.TRISC1)
    #define PRP17_WR_IO  (LATCbits.LATC1)
    #define PRP17_RD_IO  (PORTCbits.RC1)
    //RP18
    #define PRP18_TRIS   (TRISCbits.TRISC2)
    #define PRP18_WR_IO  (LATCbits.LATC2)
    #define PRP18_RD_IO  (PORTCbits.RC2)
    //RP19
    #define PRP19_TRIS   (TRISCbits.TRISC3)
    #define PRP19_WR_IO  (LATCbits.LATC3)
    #define PRP19_RD_IO  (PORTCbits.RC3)
    //RP20
    #define PRP20_TRIS   (TRISCbits.TRISC4)
    #define PRP20_WR_IO  (LATCbits.LATC4)
    #define PRP20_RD_IO  (PORTCbits.RC4)
    //RP21
    #define PRP21_TRIS   (TRISCbits.TRISC5)
    #define PRP21_WR_IO  (LATCbits.LATC5)
    #define PRP21_RD_IO  (PORTCbits.RC5)
    //RP22
    #define PRP22_TRIS   (TRISCbits.TRISC6)
    #define PRP22_WR_IO  (LATCbits.LATC6)
    #define PRP22_RD_IO  (PORTCbits.RC6)
    //RP23
    #define PRP23_TRIS   (TRISCbits.TRISC7)
    #define PRP23_WR_IO  (LATCbits.LATC7)
    #define PRP23_RD_IO  (PORTCbits.RC7)
    //RP24
    #define PRP24_TRIS   (TRISCbits.TRISC8)
    #define PRP24_WR_IO  (LATCbits.LATC8)
    #define PRP24_RD_IO  (PORTCbits.RC8)
    //RP25
    #define PRP25_TRIS   (TRISCbits.TRISC9)
    #define PRP25_WR_IO  (LATCbits.LATC9)
    #define PRP25_RD_IO  (PORTCbits.RC9)

#endif


  /* OS LOCK PPS:
  |
  |  remap OSCCONL bit
  |
  |  push reg
  |
  |  free OSCCON
  |
  |  pop reg
  |
  |_______________________________________*/
  //
 
#define LOCKPPS() __builtin_write_OSCCONL(OSCCON | 0x40); \
                  asm volatile ( "push w1 \n push w2 \n push w3 \n" \
                                 "mov #OSCCON,w1 \n" \
                                 "mov #0x46, w2 \n" \
                 "mov #0x57, w3 \n" \
             "mov.b w2,[w1] \n" \
             "mov.b w3,[w1] \n" \
             "bset OSCCON, #6 \n" \
             "pop w3 \n pop w2 \n pop w1");

  /* OS UNLOCK PPS:
  |
  |  clear OSCCONL bit
  |
  |  push reg
  |
  |  free OSCCON
  |
  |  pop reg
  |
  |_______________________________________*/
 

#define UNLOCKPPS()  __builtin_write_OSCCONL(OSCCON & 0xbf); \
                     asm volatile ( "push w1 \n push w2 \n push w3 \n" \
                                    "mov #OSCCON, w1 \n" \
                                    "mov #0x46, w2 \n" \
                                    "mov #0x57, w3 \n" \
                                    "mov.b w2, [w1] \n" \
                                    "mov.b w3, [w1] \n" \
                                    "bclr OSCCON, #6 \n" \
                                    "pop w3 \n pop w2 \n pop w1");


#define PIN_INPUT  (1)
#define PIN_OUTPUT (0)

  /* OS PPS SET:
  |
  |  a = PPS Mode PIN (PIN_OUTPUT/PIN_INPUT)
  |
  |  b = PPS PIN NUMBER (RP0,RP1,...)
  |
  |  c = PPS INPUT FUNCTION (U1RX, U2RX,... )
  |
  |  d = PPS OUTPUT FUNCTION (U1TX, U2TX,... )
  |
  |  examples:
  |         
  |       SetPPS(PIN_INPUT,RP0,U1RX,ONULL);
  |
  |       SetPPS(PIN_OUTPUT,RP1,INULL,U1TX);
  |
  |_______________________________________*/

#define SetPPS(a,b,c,d) P##b##_TRIS = (a); \
                        if(a) I##c = (b); \
    else  O##b = (c);
   

  /* OS PPS SET input PIN:
  |
  |  a = PPS PIN NUMBER (RP0,RP1,...)
  |
  |  b = PPS INPUT FUNCTION (U1RX, U2RX,... )
  |
  |  example:
  |         
  |       SetPPSinputFunction(RP0,U1RX);
  |
  |_______________________________________*/

#define SetPPSinputFuncition(a,b) P##a##_TRIS = 1; \
                                  I##b = (a);

#define SetPPSinput(a) P##a##_TRIS = 1;
   
  /* OS PPS SET output PIN:
  |
  |  a = PPS PIN NUMBER (RP0,RP1,...)
  |
  |  b = PPS OUTPUT FUNCTION (U1TX, U2TX,... )
  |
  |  example:
  |         
  |       SetPPSoutputFunction(RP0,U1TX);
  |
  |_______________________________________*/

#define SetPPSoutputFunction(a,b) P##a##_TRIS = 0; \
                                  O##a = (F##b);    

#define SetPPSoutput(a) P##a##_TRIS = 0;

  /* OS PPS WRITE PIN:
  |
  |  a = PPS PIN NUMBER (RP0,RP1,...)
  |
  |  b = value;
  |
  |  example:
  |         
  |       WritePPSpin(RP0,0);
  |
  |_______________________________________*/

#define WritePPSpin(a,b)  P##a##_WR_IO = b


  /* OS PPS READ PIN:
  |
  |  a = PPS PIN NUMBER (RP0,RP1,...)
  |
  |  return value
  |
  |  example:
  |         
  |       ReadPPSpin(RP0);
  |
  |_______________________________________*/

#define ReadPPSpin(a)  P##a##_RD_IO

                         
  /* OS PPS SET FULL UART:
  |
  |  a = RX PPS PIN (RP0,RP1,...)
  |
  |  b = TX PPS PIN (RP0,RP1,...)
  |
  |  c = CTS PPS PIN (RP0,RP1,...)
  |
  |  d = RTS PPS PIN (RP0,RP1,...)
  |
  |  examples:
  |                        RX  TX  RTS CTS
  |       SetFullUART1wpps(RP0,RP2,RP1,RP3)
  |
  |_______________________________________*/
#define SetFullUART1wpps(a,b,c,d)  \
                    P##a##_TRIS = 1; P##b##_TRIS = 0; \
    P##c##_TRIS = 1; P##d##_TRIS = 0; \
      IU1RX = a; IU1RTS = c; \
      O##b = OU1TX; O##d = OU1CTS

#define SetFullUART2wpps(a,b,c,d)  \
                    P##a##_TRIS = 1; P##b##_TRIS = 0; \
    P##c##_TRIS = 1; P##d##_TRIS = 0; \
      IU2RX = a; IU2RTS = c; \
      O##b = OU2TX; O##d = OU2CTS                        
     

  /* OS PPS SET HALF UART:
  |
  |  a = RX PPS PIN (RP0,RP1,...)
  |
  |  b = TX PPS PIN (RP0,RP1,...)
  |
  |  examples:
  |                     RX  TX
  |       SetUART1wpps(RP0,RP1)
  |
  |_______________________________________*/
#define SetUART1wpps(a,b) \
                  P##a##_TRIS = 1; P##b##_TRIS = 0; \
      IU1RX = a; O##b = FU1TX;


#define SetUART2wpps(a,b) \
                    P##a##_TRIS = 1; P##b##_TRIS = 0; \
      IU2RX = a; O##b = FU2TX;
     







saludos.

Desconectado alexiel

  • PIC10
  • *
  • Mensajes: 31
Re: Problemas Rp15 y Rp14 como RX del UART en dspic33fj64gp802.
« Respuesta #4 en: 14 de Marzo de 2010, 14:55:28 »
Hola micronoob, gracias por ayudarme en este problema.
Aquí te dejo la función que utilizo para configurar el UART y los pines remapables Rp15 y Rp14.
Una pregunta, qué diferencia hay en usar tu parte de codigo para configurar esto y usar los registros RPOR y RPIN?
Código: C
  1. void UART_inic(void)
  2. {
  3.     char Buf[3] = {'A','B','\0'};                              //Array initial
  4.     unsigned int U2MODEvalue;                            //Holds the value of uart config reg  
  5.     unsigned int U2STAvalue;                            // Holds the information regarding uart TX & RX interrupt modes
  6.    
  7.     CloseUART2();                                        // Turn off UART1module
  8.              
  9.     RPOR7bits.RP14R =     0b00101;       //Configuro el Rp14 como TX del UART2
  10.     RPINR19bits.U2RXR = 0b01111;        //Configuro el Rp15 como RX del UART2
  11.  
  12.     TRISBbits.TRISB14 = 0;      
  13.     TRISBbits.TRISB15 = 1;      
  14.  
  15. ///////////////////////////////////////////////////////////////////////////////////////////////////
  16.             // Configure uart2 receive and transmit interrupt
  17.     ConfigIntUART2(UART_RX_INT_DIS & UART_RX_INT_PR2 & UART_TX_INT_EN & UART_TX_INT_PR6);
  18.  
  19. /* Configure UART2 module to transmit 8 bit data with one stopbit */
  20.  
  21.     U2MODEvalue = UART_EN & UART_IDLE_STOP & UART_IrDA_DISABLE & UART_MODE_SIMPLEX &              UART_UEN_00 & UART_DIS_WAKE & UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_UXRX_IDLE_ONE & UART_BRGH_SIXTEEN & UART_NO_PAR_8BIT & UART_1STOPBIT;                                                        
  22.  
  23.     U2STAvalue = UART_INT_TX_BUF_EMPTY  & UART_IrDA_POL_INV_ZERO & UART_INT_RX_CHAR;  
  24.  
  25.     OpenUART2(U2MODEvalue, U2STAvalue, BRGVAL);          
  26.     U2STAbits.UTXEN = 1;                  
  27.     putsUART2 ((unsigned int *)Buf);       //initial Transmission
  28.     while(BusyUART2());
  29. }