Completely Turning of Rx/Tx lines

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Completely Turning of Rx/Tx lines

2,693件の閲覧回数
burgeh
Contributor IV

Greetings,

I am using KDS v3.2 with Processor expert on a MK22FN256LVH12 on a Custom board.

I am currently using a Bluetooth chip connected to the UART2 of chip, and I've noticed that even when I turn the bluetooth chip off, and turn the reset low (resetting it) that my UART lines remain at 3.3V. This is even when I set the microcontroller to VLSS1 to sleep.

I've tried setting the UART pins to pulldown, pullup, open drain, no open drain, basically anything to see if the pin settings will stop it from being awake. Any suggestions or thoughts would be appreciated!

ラベル(2)
10 返答(返信)

2,344件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Before enter low power mode, please try to configure the pin as GPIO function and then output low voltage.
When you want these pins act as UART function, then you need to reconfigure them as UART pins.(PORTx_PCRn[MUX])

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

2,344件の閲覧回数
burgeh
Contributor IV

So the two pins I'm working on are pins 59 and 60 on the 64 pin MK22FN micro, thus my code I thought was correct is shown below, but that doesn't seem correct. What am I missing?

  PORTD_PCR2 |= (PORT_PCR_MUX(1));
  PORTD_PCR3 |= (PORT_PCR_MUX(1));
////
  GPIOD_PDOR = GPIOD_PDOR & (0xFFFFFFFB);
  GPIOD_PDOR = GPIOD_PDOR & (0xFFFFFFF7);

0 件の賞賛
返信

2,344件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Considering that you are using Processor Expert, you can refer the function generated by Processor Expert.

Bit_IO LDD.png

  /* Enable device clock gate */
  /* SIM_SCGC5: PORTD=1 */
  SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;
  /* Configure pin as output */
  /* GPIOD_PDDR: PDD|=4 */
  GPIOD_PDDR |= GPIO_PDDR_PDD(0x04);
  /* Set initialization value */
  /* GPIOD_PDOR: PDO|=4 */
  GPIOD_PDOR |= GPIO_PDOR_PDO(0x04);
  /* Initialization of pin routing */
  /* PORTD_PCR2: ISF=0,MUX=1 */
  PORTD_PCR2 = (uint32_t)((PORTD_PCR2 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK |
                PORT_PCR_MUX(0x06)
               )) | (uint32_t)(
                PORT_PCR_MUX(0x01)
               ));

  /* SIM_SCGC5: PORTD=1 */
  SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;
  /* Configure pin as output */
  /* GPIOD_PDDR: PDD|=8 */
  GPIOD_PDDR |= GPIO_PDDR_PDD(0x08);
  /* Set initialization value */
  /* GPIOD_PDOR: PDO|=8 */
  GPIOD_PDOR |= GPIO_PDOR_PDO(0x08);
  /* Initialization of pin routing */
  /* PORTD_PCR3: ISF=0,MUX=1 */
  PORTD_PCR3 = (uint32_t)((PORTD_PCR3 & (uint32_t)~(uint32_t)(
                PORT_PCR_ISF_MASK |
                PORT_PCR_MUX(0x06)
               )) | (uint32_t)(
                PORT_PCR_MUX(0x01)
               ));

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,344件の閲覧回数
burgeh
Contributor IV

Thank you. This worked to the same extent that bobpaddock'‌s example that I modified did. The TX line seems to stay low now, but the RX remains at 2.7V. The board now draws a lot more current when it is trying/in sleep mode. 1.3mA without the code change and 35mA with, even though the pins are set to be low. Any thoughts?

0 件の賞賛
返信

2,344件の閲覧回数
bobpaddock
Senior Contributor III

Assign not OR the MUX value. 
ORing MUX(1) with the MUX(UART) value will give something you probably don't want.

Having 'Magic Numbers' like 0xFFFFFFFx in code is in general bad practice.
#define or enum a mask, or preferably use something from the manufactures header file to create the mask.

No one, including you years from now, will know what those values mean to help you if that is the issue.

0 件の賞賛
返信

2,344件の閲覧回数
burgeh
Contributor IV

I see that is a good point about magic numbers. So here is my revision, but I still do not see a change.

PORTD_PCR2 = 0001; //change mux to alt 1 which is GPIO
PORTD_PCR3 = 0001; //change mux to alt 1 which is GPIO
GPIOD_PDDR = 0x0C; //Pin is configured as general-purpose output

GPIOD_PDOR = 0x0; //Logic level 0 is driven on pin

pastedImage_2.png

0 件の賞賛
返信

2,344件の閲覧回数
bobpaddock
Senior Contributor III

PORTD_PCR2 = 0001; //change mux to alt 1 which is GPIO
PORTD_PCR3 = 0001; //change mux to alt 1 which is GPIO
GPIOD_PDDR = 0x0C; //Pin is configured as general-purpose output

GPIOD_PDOR = 0x0; //Logic level 0 is driven on pin

Went a little to far in reducing the code.
Still need the MUX() as it hides shifts and masks.
Still need the AND for the GIO.  Only want to change one pin, not all of them.

Something along this line:

#define MEANINGFUL_NAME_bm (0x00000040UL)

/* _bm means Bit Mask */

PORTD_PCR2 = PORT_PCR_MUX(1U);

PORTD_PCR3  = PORT_PCR_MUX(1U);

GPIOD_PDOR &= ~MEANINGFUL_NAME_bm; /* Drive output low */

GPIOD_PDDR &= ~MEANINGFUL_NAME_bm; /* Set pin to output [Check data sheet to see if this should be a OR, don't have data sheet at hand] */

Note that I swapped PDOR and PDDR to prevent a short glitch on the output.

2,344件の閲覧回数
burgeh
Contributor IV

I believe it is an OR...With the bit mask why did you choose 0x040? If its pins 2 and 3 of port D wouldn't it be 0xC? Shown here?

pastedImage_1.png

Using your example it successfully turned one pin low, but the other hovers at 2.7 volts now and is draining a lot of current. Specifically Pin 59 which would be Port D pin 2.

This got one pin low... Which would be Port D pin 3 (pin 60)

#define MEANINGFUL_NAME_bm (0x00000040UL)
PORTD_PCR2 = PORT_PCR_MUX(1U);
PORTD_PCR3 = PORT_PCR_MUX(1U);
GPIOD_PDOR &= ~MEANINGFUL_NAME_bm; /* Drive output low */
GPIOD_PDDR |= ~MEANINGFUL_NAME_bm;

0 件の賞賛
返信

2,344件の閲覧回数
bobpaddock
Senior Contributor III

The 0x40 was an arbitrary number, I picked.
As I said didn't have data sheet at hand.
0x0C would be correct as you showed.

For an OR not not use the compliment operator '~'.

0 件の賞賛
返信

2,344件の閲覧回数
bobpaddock
Senior Contributor III

Should read 'OR do not use...'.

0 件の賞賛
返信