[技术问题解答] 关于K21的7816接口的问题

[复制链接]
3074|17
 楼主| LZR13179 发表于 2015-1-21 20:02 | 显示全部楼层 |阅读模式
  1. void main (void)
  2. {
  3.   unsigned int i,core_clk_mhz,periph_clk_mhz;     
  4.   extern int mcg_clk_hz,core_clk_khz,periph_clk_khz;
  5. #ifdef VLPR_TEST
  6.   int fast_irc_freq = 4000000;
  7.         /* auto trim internal fast IRC to 4MHz */
  8.         atc(FAST_IRC, fast_irc_freq, mcg_clk_hz);
  9.         
  10.         /* PEE -> PBE */
  11.         mcg_clk_hz = pee_pbe(CLK0_FREQ_HZ);
  12.         /* PBE -> FBE */
  13.         mcg_clk_hz = pbe_fbe(CLK0_FREQ_HZ);
  14.         /* FBE -> FBI */
  15.         mcg_clk_hz = fbe_fbi(fast_irc_freq,FAST_IRC);
  16.         /* FBI -> BLPI */
  17.         mcg_clk_hz = fbi_blpi(fast_irc_freq,FAST_IRC);   
  18.         SIM_CLKDIV1  =  0x00110000;   
  19.         core_clk_khz = mcg_clk_hz/1000;
  20.         periph_clk_khz = core_clk_khz;
  21.         /* Change UART baud rate to 19200 under VLPR mode*/
  22.         uart_init (TERM_PORT, core_clk_khz, 19200);
  23.         printf("\n In blpi mode now ready for entry into VLPR  \n\n");
  24.         enter_vlpr(0);
  25.         PORTC_PCR3 = ( PORT_PCR_MUX(1));
  26.         PORTA_PCR18 = PORT_PCR_MUX(4);//PTA18 as FTM_CLKIN0
  27. #endif
  28.         core_clk_mhz = core_clk_khz/1000;
  29.         periph_clk_mhz = periph_clk_khz/1000;
  30.       
  31.         <span style="background-color: Red;">//CPU =96M, Bus =48M
  32.         //init GPIO, refer to the Firebird Daughter card schematic
  33.         </span>
  34.         // SIM0_VEN - LCD_P33/PTC13/UART4_CTS
  35.         PORTC_PCR13 = PORT_PCR_MUX(1);
  36.         GPIOC_PDOR &= ~(SIM0_VEN_BIT); //VEN set as 0
  37.         GPIOC_PDDR |= (SIM0_VEN_BIT);
  38.          
  39.         // SIM0_RST - LCD_P39/PTC19/UART3_CTS
  40.         PORTC_PCR19 = PORT_PCR_MUX(1);
  41.         GPIOC_PDOR &= ~(SIM0_RST_BIT); //reset set as 0
  42.         GPIOC_PDDR |= (SIM0_RST_BIT);
  43.         
  44. #ifndef VLPR_TEST// in VLPR mode , use FB_CLK for SIM_CLK         
  45.         // SIM0_CLK - LCD_P46/PTD6/FTM0_CH6/FTM0_FLT0
  46.         PORTD_PCR6 = PORT_PCR_MUX(4);//FTM0
  47. #endif                  
  48.         // SIM0_PD - LCD_P38/PTC18/UART3_RTS
  49.         PORTC_PCR18 = PORT_PCR_MUX(1);
  50.         GPIOC_PDDR &= ~(SIM0_PD_BIT);//GPIO input
  51.          
  52.         // SIM0_DATA - LCD_P47/PTD7/CMT_IRO/_UART0_TX
  53.         PORTD_PCR7 = PORT_PCR_MUX(3);
  54.         //PORTB_PCR17 = PORT_PCR_MUX(3);
  55.           printf("\n Kinetis ISO7816 test \n");
  56.         
  57.         if(SIM_PD)
  58.           printf("No Smart Card insert in slot 0\n");
  59.         while(SIM_PD);
  60.         printf("Smart Card inserted in slot 0\n");
  61. #ifndef VLPR_TEST        
  62.         //init the SIM clock, using FTM0_CH6
  63.         SIM_SCGC6 |= SIM_SCGC6_FTM0_MASK;
  64.         FTM0_STATUS;
  65.         FTM0_STATUS = 0;
  66.         //prescale = 1, clock source = bus clock
  67.         <font color="Red">FTM0_CNTIN = 0;</font>

  68.         FTM0_C6SC = FTM_CnSC_MSA_MASK|FTM_CnSC_ELSA_MASK; //ELSB:ELSA= 0b01, MSB:MSA= 0b01 means output compare, tougle output on match
  69.         FTM0_C6V = 1;
  70.         <font color="Red">FTM0_MOD = (periph_clk_mhz/2)/SIM_CLK -1; //generate 2MHz CLK
  71. </font>
  72.         FTM0_MODE |= FTM_MODE_FTMEN_MASK;
  73.         FTM0_OUTMASK &= ~FTM_OUTMASK_CH6OM_MASK;
  74.         <font color="Red">FTM0_SC = FTM_SC_PS(0)|
  75.                   FTM_SC_CLKS(1);</font>
  76. #else
  77.         PORTC_PCR3 = ( PORT_PCR_MUX(0x5));
  78. #endif   
  79.         //init UART to ISO7816 format
  80.         //The SIM_CLK is 2MHz, so the baudrate is 2M/372
  81.         status = IDLE_STATE;
  82.         i = (uint16)((core_clk_mhz)*Fi/(SIM_CLK * 16));
  83. //        SIM_SOPT5 = SIM_SOPT5_UART0TXSRC(0)|SIM_SOPT5_UART0RXSRC(0);
  84.         SIM_SCGC4 |=  SIM_SCGC4_UART0_MASK;
  85.         UART0_BDH |= UART_BDH_SBR(((i & 0x1F00) >> 8));
  86.         UART0_BDL = (uint8)(i & UART_BDL_SBR_MASK);
  87. #ifdef VLPR_TEST
  88.         UART0_C4 = 0x10;  //refine the baudrate
  89. #else
  90.         UART0_C4 = 0x00;
  91. #endif
  92.         //printf("UART0_WP7816T1 = 0x%x\n",UART0_WP7816T1);
  93.         UART0_WP7816T0 = 1; UART0_WF7816 = 1;//set the WT = 960*1*1 =960 etu
  94. //       UART0_WP7816T0 = 1; UART0_WF7816 = 10;//set the WT = 960*1*10 =9600 etu
  95.         //UART0_C7816 |= UART_C7816_TTYPE_MASK;
  96.         //UART0_C7816 |= UART_C7816_ISO_7816E_MASK;
  97.         //printf("UART0_WP7816T1 = 0x%x\n",UART0_WP7816T1);
  98.         //one wire mode, 9bit mode, Even parity
  99.         UART0_C1 = UART_C1_LOOPS_MASK |
  100.                    UART_C1_RSRC_MASK |
  101.                    UART_C1_M_MASK |
  102. //                 UART_C1_PT_MASK| //set Odd parity to see if the NACK error detect and retransfer
  103.                    UART_C1_PE_MASK;
  104.         
  105.         UART0_S2 = 0;
  106. #ifdef INVERSE
  107.         UART0_S2 |= UART_S2_MSBF_MASK | UART_S2_RXINV_MASK;  // inverse mode
  108. #endif
  109.         UART0_MODEM = 0;
  110.         UART0_C3 |= (UART_C3_ORIE_MASK|UART_C3_NEIE_MASK|UART_C3_FEIE_MASK|UART_C3_PEIE_MASK);
  111. #ifdef INVERSE
  112. //        UART0_C3 |= UART_C3_TXINV_MASK; //inverse mode
  113. #endif
  114.         UART0_C4 &= ~(UART_C4_MAEN1_MASK|UART_C4_MAEN2_MASK);
  115.         UART0_C5 = 0;
  116.         UART0_C7816 = UART_C7816_INIT_MASK |
  117.                       UART_C7816_ISO_7816E_MASK |
  118.                       UART_C7816_ONACK_MASK |
  119.                       UART_C7816_ANACK_MASK;
  120.         UART0_C2 =   UART_C2_TE_MASK | UART_C2_RE_MASK;
  121.         
  122. #ifdef  NACK_THRESHOLD_TEST
  123. //        UART0_PFIFO = UART_PFIFO_TXFE_MASK | UART_PFIFO_RXFE_MASK;
  124.         txt_cnt = 0;
  125.         rxt_cnt = 0;
  126.         i = 1;
  127.         UART0_ET7816 = (i<<4)|i;
  128. #endif
  129. //        UART0_IE7816 |= (UART_IE7816_WTE_MASK|UART_IE7816_CWTE_MASK|UART_IE7816_BWTE_MASK|UART_IE7816_GTVE_MASK);
  130. //        UART0_IE7816 |= (UART_IE7816_WTE_MASK|UART_IE7816_GTVE_MASK);
  131. #if 0        
  132.         UART0_C3 |= UART_C3_TXDIR_MASK; //set the TX pin as output

  133.         UART0_TL7816 = 2; //the TLEN does not count the NAD, PCB, LEN, LRC, if use CRC, it should + 1
  134.         UART0_C2 |= UART_C2_TE_MASK; //enable TX
  135.         UART0_D = 0x55;
  136.         UART0_D = 0xaa;
  137. #endif
  138.         if(ATR()!=0)
  139.         {
  140.           printf("ATR failed!\n");
  141.           goto exit0;
  142.         }
  143.         else
  144.           printf("ATR successfull!\n");

  145.         //T=0 transport
  146.         Trans_T0();
  147.         
  148.         //T=1 transport
  149.         Trans_T1();
  150. exit0:
  151.         while(1)
  152.         {
  153.          }
  154. }
以上是7816的demo中代码,对于以上代码的理解是
1、7816协议接口的clk由FTM产生;
2、根据代码中给定sysclk 【Bus Clock=48M】,由FTM0_SC的配置可以得到 FTM_CLK=sysclk/(2^0);
又FTM0_CNT=0(默认为0);FTM0_CNTIN=0;                       
PWM周期= (MOD - CNTIN+1)*FTM_CLK
这个和代码中注释的信息generate 2MHz CLK是否是有问题【备注不定义 VLPR_TEST】
即代码中MOD=(periph_clk_mhz/2)/SIM_CLK -1=48M/2/2 -1=12M-1 【其中#define SIM_CLK 2 //in MHz from FTM0_CH6】
FSL_TICS_ZJJ 发表于 2015-1-22 14:50 | 显示全部楼层
楼主代码哪来的?
还有你用的芯片全称是什么?
 楼主| LZR13179 发表于 2015-1-23 09:06 | 显示全部楼层
FSL_TICS_ZJJ 发表于 2015-1-22 14:50
楼主代码哪来的?
还有你用的芯片全称是什么?

代码是参考这个代码
目前使用的单片机的全称是K21F120M
 楼主| LZR13179 发表于 2015-1-23 09:09 | 显示全部楼层
刚才的链接是个K53的ISO7816的代码,

iso7816.rar

6.04 KB, 下载次数: 22

 楼主| LZR13179 发表于 2015-1-23 09:10 | 显示全部楼层
FSL_TICS_ZJJ 发表于 2015-1-22 14:50
楼主代码哪来的?
还有你用的芯片全称是什么?

我将参考的代码的源码上传到第4楼
 楼主| LZR13179 发表于 2015-1-23 09:32 | 显示全部楼层
现在可以看到波形的实践波形是为2MHz的
scope_15.bmp
 楼主| LZR13179 发表于 2015-1-23 10:06 | 显示全部楼层
FSL_TICS_ZJJ 发表于 2015-1-22 14:50
楼主代码哪来的?
还有你用的芯片全称是什么?

目前K21移植demo中CLK移植正常了。但是由于参考的代码中使用是K53的ISO7816,
【这个是demo中寄存器】
UART0_WP7816T0 = 1;
UART0_WF7816 = 1;//set the WT = 960*1*1 =960 etu
【以下是K53的串口的结构体】
typedef struct UART_MemMap {
  uint8_t BDH;                                     /**< UART Baud Rate Registers:High, offset: 0x0 */
  uint8_t BDL;                                     /**< UART Baud Rate Registers: Low, offset: 0x1 */
  uint8_t C1;                                      /**< UART Control Register 1, offset: 0x2 */
  uint8_t C2;                                      /**< UART Control Register 2, offset: 0x3 */
  uint8_t S1;                                      /**< UART Status Register 1, offset: 0x4 */
  uint8_t S2;                                      /**< UART Status Register 2, offset: 0x5 */
  uint8_t C3;                                      /**< UART Control Register 3, offset: 0x6 */
  uint8_t D;                                       /**< UART Data Register, offset: 0x7 */
  uint8_t MA1;                                     /**< UART Match Address Registers 1, offset: 0x8 */
  uint8_t MA2;                                     /**< UART Match Address Registers 2, offset: 0x9 */
  uint8_t C4;                                      /**< UART Control Register 4, offset: 0xA */
  uint8_t C5;                                      /**< UART Control Register 5, offset: 0xB */
  uint8_t ED;                                      /**< UART Extended Data Register, offset: 0xC */
  uint8_t MODEM;                                   /**< UART Modem Register, offset: 0xD */
  uint8_t IR;                                      /**< UART Infrared Register, offset: 0xE */
  uint8_t RESERVED_0[1];
  uint8_t PFIFO;                                   /**< UART FIFO Parameters, offset: 0x10 */
  uint8_t CFIFO;                                   /**< UART FIFO Control Register, offset: 0x11 */
  uint8_t SFIFO;                                   /**< UART FIFO Status Register, offset: 0x12 */
  uint8_t TWFIFO;                                  /**< UART FIFO Transmit Watermark, offset: 0x13 */
  uint8_t TCFIFO;                                  /**< UART FIFO Transmit Count, offset: 0x14 */
  uint8_t RWFIFO;                                  /**< UART FIFO Receive Watermark, offset: 0x15 */
  uint8_t RCFIFO;                                  /**< UART FIFO Receive Count, offset: 0x16 */
  uint8_t RESERVED_1[1];
  uint8_t C7816;                                   /**< UART 7816 Control Register, offset: 0x18 */
  uint8_t IE7816;                                  /**< UART 7816 Interrupt Enable Register, offset: 0x19 */
  uint8_t IS7816;                                  /**< UART 7816 Interrupt Status Register, offset: 0x1A */
  union {                                          /* offset: 0x1B */
    uint8_t WP7816_T_TYPE0;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
    uint8_t WP7816_T_TYPE1;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
  };
  uint8_t WN7816;                                  /**< UART 7816 Wait N Register, offset: 0x1C */
  uint8_t WF7816;                                  /**< UART 7816 Wait FD Register, offset: 0x1D */
  uint8_t ET7816;                                  /**< UART 7816 Error Threshold Register, offset: 0x1E */
  uint8_t TL7816;                                  /**< UART 7816 Transmit Length Register, offset: 0x1F */
} volatile *UART_MemMapPtr;
【而在K21中没有UART0_WP7816T0 该寄存器】
下面关于WP7816相关有两处关于WP7816的相关,请问移植的时候使用那个寄存器替代UART0_WP7816T0 = 1;
typedef struct UART_MemMap {
  uint8_t BDH;                                     /**< UART Baud Rate Registers: High, offset: 0x0 */
  uint8_t BDL;                                     /**< UART Baud Rate Registers: Low, offset: 0x1 */
  uint8_t C1;                                      /**< UART Control Register 1, offset: 0x2 */
  uint8_t C2;                                      /**< UART Control Register 2, offset: 0x3 */
  uint8_t S1;                                      /**< UART Status Register 1, offset: 0x4 */
  uint8_t S2;                                      /**< UART Status Register 2, offset: 0x5 */
  uint8_t C3;                                      /**< UART Control Register 3, offset: 0x6 */
  uint8_t D;                                       /**< UART Data Register, offset: 0x7 */
  uint8_t MA1;                                     /**< UART Match Address Registers 1, offset: 0x8 */
  uint8_t MA2;                                     /**< UART Match Address Registers 2, offset: 0x9 */
  uint8_t C4;                                      /**< UART Control Register 4, offset: 0xA */
  uint8_t C5;                                      /**< UART Control Register 5, offset: 0xB */
  uint8_t ED;                                      /**< UART Extended Data Register, offset: 0xC */
  uint8_t MODEM;                                   /**< UART Modem Register, offset: 0xD */
  uint8_t IR;                                      /**< UART Infrared Register, offset: 0xE */
  uint8_t RESERVED_0[1];
  uint8_t PFIFO;                                   /**< UART FIFO Parameters, offset: 0x10 */
  uint8_t CFIFO;                                   /**< UART FIFO Control Register, offset: 0x11 */
  uint8_t SFIFO;                                   /**< UART FIFO Status Register, offset: 0x12 */
  uint8_t TWFIFO;                                  /**< UART FIFO Transmit Watermark, offset: 0x13 */
  uint8_t TCFIFO;                                  /**< UART FIFO Transmit Count, offset: 0x14 */
  uint8_t RWFIFO;                                  /**< UART FIFO Receive Watermark, offset: 0x15 */
  uint8_t RCFIFO;                                  /**< UART FIFO Receive Count, offset: 0x16 */
  uint8_t RESERVED_1[1];
  uint8_t C7816;                                   /**< UART 7816 Control Register, offset: 0x18 */
  uint8_t IE7816;                                  /**< UART 7816 Interrupt Enable Register, offset: 0x19 */
  uint8_t IS7816;                                  /**< UART 7816 Interrupt Status Register, offset: 0x1A */
  uint8_t WP7816;                                  /**< UART 7816 Wait Parameter Register, offset: 0x1B */
  uint8_t WN7816;                                  /**< UART 7816 Wait N Register, offset: 0x1C */
  uint8_t WF7816;                                  /**< UART 7816 Wait FD Register, offset: 0x1D */
  uint8_t ET7816;                                  /**< UART 7816 Error Threshold Register, offset: 0x1E */
  uint8_t TL7816;                                  /**< UART 7816 Transmit Length Register, offset: 0x1F */
  uint8_t RESERVED_2[1];
  uint8_t C6;                                      /**< UART CEA709.1-B Control Register 6, offset: 0x21 */
  uint8_t PCTH;                                    /**< UART CEA709.1-B Packet Cycle Time Counter High, offset: 0x22 */
  uint8_t PCTL;                                    /**< UART CEA709.1-B Packet Cycle Time Counter Low, offset: 0x23 */
  uint8_t B1T;                                     /**< UART CEA709.1-B Beta1 Timer, offset: 0x24 */
  uint8_t SDTH;                                    /**< UART CEA709.1-B Secondary Delay Timer High, offset: 0x25 */
  uint8_t SDTL;                                    /**< UART CEA709.1-B Secondary Delay Timer Low, offset: 0x26 */
  uint8_t PRE;                                     /**< UART CEA709.1-B Preamble, offset: 0x27 */
  uint8_t TPL;                                     /**< UART CEA709.1-B Transmit Packet Length, offset: 0x28 */
  uint8_t IE;                                      /**< UART CEA709.1-B Interrupt Enable Register, offset: 0x29 */
  uint8_t WB;                                      /**< UART CEA709.1-B WBASE, offset: 0x2A */
  uint8_t S3;                                      /**< UART CEA709.1-B Status Register, offset: 0x2B */
  uint8_t S4;                                      /**< UART CEA709.1-B Status Register, offset: 0x2C */
  uint8_t RPL;                                     /**< UART CEA709.1-B Received Packet Length, offset: 0x2D */
  uint8_t RPREL;                                   /**< UART CEA709.1-B Received Preamble Length, offset: 0x2E */
  uint8_t CPW;                                     /**< UART CEA709.1-B Collision Pulse Width, offset: 0x2F */
  uint8_t RIDT;                                    /**< UART CEA709.1-B Receive Indeterminate Time, offset: 0x30 */
  uint8_t TIDT;                                    /**< UART CEA709.1-B Transmit Indeterminate Time, offset: 0x31 */
  uint8_t RESERVED_3[8];
  uint8_t AP7816A_T0;                              /**< UART 7816 ATR Duration Timer Register A, offset: 0x3A */
  uint8_t AP7816B_T0;                              /**< UART 7816 ATR Duration Timer Register B, offset: 0x3B */
  union {                                          /* offset: 0x3C */
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T0;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T0;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE0;
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T1;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T1;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE1;
  };
  uint8_t WGP7816_T1;                              /**< UART 7816 Wait and Guard Parameter Register, offset: 0x3E */
  uint8_t WP7816C_T1;                              /**< UART 7816 Wait Parameter Register C, offset: 0x3F */
} volatile *UART_MemMapPtr;
FSL_TICS_ZJJ 发表于 2015-1-23 10:25 | 显示全部楼层
实际K21也是有UART0_WP7816T0寄存器的,而且地址和K53的是一样的。
你直接用UART0_WP7816T0 = 1; 会报错吗?
看看头文件中有没有这个定义。
 楼主| LZR13179 发表于 2015-1-23 10:33 | 显示全部楼层
FSL_TICS_ZJJ 发表于 2015-1-23 10:25
实际K21也是有UART0_WP7816T0寄存器的,而且地址和K53的是一样的。
你直接用UART0_WP7816T0 = 1; 会报错吗 ...

这个是K53  
union {                                          /* offset: 0x1B */
    uint8_t WP7816_T_TYPE0;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
    uint8_t WP7816_T_TYPE1;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
  };
和下面的
uint8_t WP7816;                                  /**< UART 7816 Wait Parameter Register, offset: 0x1B */
相同
 楼主| LZR13179 发表于 2015-1-23 10:35 | 显示全部楼层
LZR13179 发表于 2015-1-23 10:33
这个是K53  
union {                                          /* offset: 0x1B */
    uint8_t WP7816 ...

但是不明白与K21的
前面的WP7816与
union {                                          /* offset: 0x3C */
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T0;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T0;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE0;
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T1;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T1;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE1;
  };
的区别
FSL_TICS_ZJJ 发表于 2015-1-23 10:50 | 显示全部楼层
LZR13179 发表于 2015-1-23 10:35
但是不明白与K21的
前面的WP7816与
union {                                          /* offset: 0x3C  ...

我认为还是用之前定义的:
uint8_t WP7816;                                  /**< UART 7816 Wait Parameter Register, offset: 0x1B */
因为这个偏移地址和实际RM中的寄存器表是对应的:
58.jpg

而后面定义的:union {                                          /* offset: 0x3C */
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T0;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T0;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE0;
    struct {                                         /* offset: 0x3C */
      uint8_t WP7816A_T1;                              /**< UART 7816 Wait Parameter Register A, offset: 0x3C */
      uint8_t WP7816B_T1;                              /**< UART 7816 Wait Parameter Register B, offset: 0x3D */
    } TYPE1;
  };

实际寄存器偏移地址,最高到0x31,代码定义到0X3C应该是不可用的:
59.jpg

 楼主| LZR13179 发表于 2015-1-26 14:48 | 显示全部楼层
本帖最后由 LZR13179 于 2015-1-26 14:51 编辑
FSL_TICS_ZJJ 发表于 2015-1-23 10:50
我认为还是用之前定义的:
uint8_t WP7816;                                  /**< UART 7816 Wait Para ...

使用 UART_WP7816_REG(ptr) = 1;在K21的工程下,出现****default_isr entered on vector 3*****;
对代码进行debug发现是执行 UART_WP7816_REG(ptr) = 1;的时候(K21使用 UART_WP7816_REG(ptr) = 1;来替代K53中UART0_WP7816T0 = 1;)
 楼主| LZR13179 发表于 2015-1-26 14:56 | 显示全部楼层
LZR13179 发表于 2015-1-26 14:48
使用 UART_WP7816_REG(ptr) = 1;在K21的工程下,出现****default_isr entered on vector 3*****;
对代码 ...

而使用 UART_WP7816A_T0_REG(base)和UART_WP7816B_T0_REG(base)来替代  K53的WP7816的时候也会出现相同的错误提示
Thefantasy 发表于 2015-1-26 20:46 | 显示全部楼层
实际K21也是有UART0_WP7816T0寄存器的,而且地址和K53的是一样的。
你直接用UART0_WP7816T0 = 1; 会报错吗?
看看头文件中有没有这个定义。
 楼主| LZR13179 发表于 2015-1-27 10:29 | 显示全部楼层
Thefantasy 发表于 2015-1-26 20:46
实际K21也是有UART0_WP7816T0寄存器的,而且地址和K53的是一样的。
你直接用UART0_WP7816T0 = 1; 会报错吗 ...

这个是K53中的WP7816T0的寄存器的
union {                                          /* offset: 0x1B */
    uint8_t WP7816_T_TYPE0;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
    uint8_t WP7816_T_TYPE1;                          /**< UART 7816 Wait Parameter Register, offset: 0x1B */
  };
下面是K21的
  uint8_t WP7816;                                  /**< UART 7816 Wait Parameter Register, offset: 0x1B */
在使用的时候出现硬件错误的提示
 楼主| LZR13179 发表于 2015-1-27 10:33 | 显示全部楼层
LZR13179 发表于 2015-1-27 10:29
这个是K53中的WP7816T0的寄存器的
union {                                          /* offset: 0x1B  ...

那时候使用的是UART1的,现在使用UART0的看看是不是有相同的问题。觉得UART1不支持,试试uart0(这个是支持7816的)相同的设置是否还会出现相同的问题
sunriselight 发表于 2015-1-27 12:17 | 显示全部楼层
实施UART0,烧例程看看
 楼主| LZR13179 发表于 2015-4-8 19:19 | 显示全部楼层
目前uart0的7816的链路层已经配置好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

87

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部