MPC5748G Devkit - how to send a HIGH to a GPIO pin

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

MPC5748G Devkit - how to send a HIGH to a GPIO pin

跳至解决方案
1,926 次查看
pmrlcbtcphtzjdq
Contributor III

Hallo!
I am pretty new to this device and I struggle with understanding few things.

I would like to send a '1' (high) value to one of the pins. I can't get it done. Here is what I tried (with S32DS IDE).

1. Pin selection and intialisation:

 I want to use PA1 in J3 area. I clicked on the 'pin_mux:PinSettings' in the components area and used the GUI to pick GPIO 1 from SIUL2 module. I set it to PA[1] and to 'Output'. After 'generating processer expert code' my pin_mux.c got updated with an entry for that pin. It reads that    .pinPortIdx = 1u, and .gpioBase = PTA . Seems fine.

Next I entered this function in my main.c to initialise:

 PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

2. Sending 'High' to a pin:

Just underneath the pin initialisation line I called this function:

PINS_DRV_WritePin(PTA, 1u, 1);

Unfortunatelly this doesn't work. I mean that I can't measure any voltage on the pin, and I can't find any register entries that change when I debug the code.

My questions are:

1. How does the MPC574G use the embedded registers to send a 'high' on a pin? In the LED example from the nxp website, a mask was used that set only one bit in the fourth byte of a register to '1', which turned the onboard LED on. Does it mean that only specific bits of a register get transfered to a pin?

2. How can i figure out what are the connections between embedded registers and pins that are set up in 'PinSettings' GUI.

3. What can i do to make my code work?

thanks in advance for your help.

Here is my main() from main.c :

int main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of Processor Expert internal initialization.                    ***/

  /* Initialze pins */
  PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

  /* send 'high' to pin*/
  PINS_DRV_WritePin(PTA, 1u, 1);

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

标签 (1)
0 项奖励
回复
1 解答
1,872 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

your code looks normal, it should work.

1) first the SIUL2.MSCR[1] register should have OBE bit set and SSS field cleared to have PTA1 pin configured as GPIO output. You can refer to this register in debugger after PINS_DRV_Init is called.

Then the value is written into port using SIUL2.GPDOn or SIUL2.PGPDOn registers. Check in a debugger GPDO1 (GPDO0_3) or PGPDO0 register.

2) should be described in SIUL2 chapter of the RM

3) did you measure right pin? PTA1 is on J3.1 header. 

Anyway you can try "hello_world_mpc5748g" demo example from S32 design studio. It toggles with a LED.

I tried to add PTA1 and output is working properly.

BR, Petr

在原帖中查看解决方案

2 回复数
1,041 次查看
antleite2001
Contributor I

PINS_DRV_WritePin has a bug. Use

PINS_DRV_SetPins

PINS_DRV_ClearPins

 

0 项奖励
回复
1,873 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

your code looks normal, it should work.

1) first the SIUL2.MSCR[1] register should have OBE bit set and SSS field cleared to have PTA1 pin configured as GPIO output. You can refer to this register in debugger after PINS_DRV_Init is called.

Then the value is written into port using SIUL2.GPDOn or SIUL2.PGPDOn registers. Check in a debugger GPDO1 (GPDO0_3) or PGPDO0 register.

2) should be described in SIUL2 chapter of the RM

3) did you measure right pin? PTA1 is on J3.1 header. 

Anyway you can try "hello_world_mpc5748g" demo example from S32 design studio. It toggles with a LED.

I tried to add PTA1 and output is working properly.

BR, Petr