Uart1 Tx pin Configuration

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Uart1 Tx pin Configuration

1,435 次查看
mustafaçakır
Contributor I

Hi everyone;

I am beginner in ARM programming  and I try to send a message via UART1 module in FRDM KL25Z board. For this job, I writed following code for Uart configuration in Uvison:

SIM->SCGC5    |= (1UL <<  9)|(1UL <<  10) | (1UL <<  12)|(1UL <<  11)|(1UL <<  13);      /* Enable Clock to Port B ,c,A& D,E */
   SIM->SCGC5|=1UL<<5; // TSI clock
    SIM->SCGC4|=1UL<<11 |1UL<<7; //UART1 clock

SIM->SOPT5|=(1UL<<17) ;
SIM->SCGC4|= 1UL<<11;



  PORTB->PCR[18] = (1UL <<  8);                      /* Pin PTB18 is GPIO */
  PORTB->PCR[19] = (1UL <<  8);                      /* Pin PTB19 is GPIO */
  PORTD->PCR[1]  = (1UL <<  8);                      /* Pin PTD1  is GPIO */

  FPTB->PDOR = (led_mask[0] |
               led_mask[1] );          /* switch Red/Green LED off  */
  FPTB->PDDR = (led_mask[0] |
               led_mask[1] );          /* enable PTB18/19 as Output */

  FPTD->PDOR = led_mask[2];            /* switch Blue LED off  */
  FPTD->PDDR = led_mask[2];            /* enable PTD1 as Output */
    
//port d
PORTD->PCR[5]=   (1UL <<  8);
  // PORTC->PCR[4]|=(1UL<<10);
 
 
 
  ///UART Configuration
  UART1->C2=0;  //Transmitter disable
 
 
 
  UART1->BDL=156;    //Baud Rate
  PORTE->PCR[0]=1UL<<9 | 1UL<<8; //Select Uart tx pin   PTE[0]
  PORTE->PCR[0] = PORT_PCR_ISF_MASK|PORT_PCR_MUX(0x3);
  PORTA->PCR[15] = PORT_PCR_ISF_MASK|PORT_PCR_MUX(0x3);
  PORTC->PCR[4]=PORT_PCR_ISF_MASK|PORT_PCR_MUX(0x3);
  UART1->C2=1UL<<3;  //Transmitter Enable

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

According to reference manual the Tx port is initially high,however ,when I tried my code there is no signal in PTE[0}. I could not understand where my mistake is . Please ,show my mistake

Thanks for your care

标记 (3)
0 项奖励
1 回复

596 次查看
jeremyzhou
NXP Employee
NXP Employee

Just according to your code that be displayed above, you also need to set the clock source of UART1 through MSG module. You can through the URL which is at below to download the sample code of FRDMKL25Z. The sample codes includes  the demo of UART module.

(www.freescale.com/FRDM-KL25Z)

0 项奖励