How to BlinkLED sample project on MPC5748G

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

How to BlinkLED sample project on MPC5748G

ソリューションへジャンプ
3,343件の閲覧回数
jzhang1
Contributor II

I'm learning the example project of BlinkLED. And it runs well. However, the example is to make LED2 blink, then I'm trying to modify the code to make other LED blinking. (let's say LED1 as an example)

Original Code:(same as a tutorial)

   void pitCh0Handler(void){

      PIT_DRV_ClearStatusFlags(INST_PIT1, 0U);        /* Clear PIT channel 0 interrupt flag */
      SIUL2->GPDO[0] ^= SIUL2_GPDO_PDO_4n_MASK;       / * Toggle LED (GPIO 0 connected to user LED 2) */
      }

   int main(void){

      CLOCK_DRV_Init(&clockMan1_InitConfig0);
      PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
      INT_SYS_InstallHandler(PIT_Ch0_IRQn, &pitCh0Handler, NULL);

      PIT_DRV_Init(INST_PIT1, &pit1_InitConfig);
      PIT_DRV_InitChannel(INST_PIT1, &pit1_ChnConfig0);
      PIT_DRV_StartChannel(INST_PIT1,0U);

   }

Modify area:

change pin mux to PA[4], which represents LED1.

SIUL2->GPDO[4] ^= SIUL2_GPDO_PDO_4n_MASK

 

Result: LED1 turns on, but never blink.

Does anyone know why?

I think the problem is "SIUL2_GPDO_PDO_4n_MASK", but I couldn't find any pin muxing in the MPC5748G datasheet!

No matter what I search ("SIUL", "GPDO", “GPDI”) inside the datasheet, I receive very limited information. Unlike MPC5744P datasheet, clear and helpful. Or am I looking at wrong data datasheet?

Please helps!

ラベル(1)
タグ(1)
1 解決策
3,240件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

See the description of GPDO register. It's 32bit register which contains four bits to control four pins.

So, GPDO[0] covers GPIOs 0-3. GPDO[1] covers GPIOs 4-7 and so on...

To write PA[4], you need to write GPDO[1] using mask SIUL2_GPDO_PDO_4n_MASK.

(Note: this depends on used header file. Sometimes the GPDO is defined as array of 32bit registers like this, sometimes it's defined as array of 8bit registers, so it is more straightforward. Both options can be used.)

Anyway, if you use SDK, why not to use SDK functions for this? There are functions like PIN_DRV_WritePin, PIN_DRV_SetPins, PIN_DRV_ClearPins, PIN_DRV_TogglePins...

Regards,

Lukas

元の投稿で解決策を見る

4 返答(返信)
3,240件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Junyi,

description of the registers and pin muxing can be found in the reference manual:

https://www.nxp.com/webapp/Download?colCode=MPC5748GRM 

There's an excel file attached inside the document:

pastedImage_2.png

Regards,

Lukas

0 件の賞賛
返信
3,240件の閲覧回数
jzhang1
Contributor II

Lukas,

Thank you for your reply.

I found the excel, but it didn't solve my question.

For LED2[PA0]:

SIUL2_GPDO_PDO_4n_MASK = 0x01000000

then how to map the LED1[PA4]? To make it turn on?

Thanks.

0 件の賞賛
返信
3,241件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

See the description of GPDO register. It's 32bit register which contains four bits to control four pins.

So, GPDO[0] covers GPIOs 0-3. GPDO[1] covers GPIOs 4-7 and so on...

To write PA[4], you need to write GPDO[1] using mask SIUL2_GPDO_PDO_4n_MASK.

(Note: this depends on used header file. Sometimes the GPDO is defined as array of 32bit registers like this, sometimes it's defined as array of 8bit registers, so it is more straightforward. Both options can be used.)

Anyway, if you use SDK, why not to use SDK functions for this? There are functions like PIN_DRV_WritePin, PIN_DRV_SetPins, PIN_DRV_ClearPins, PIN_DRV_TogglePins...

Regards,

Lukas

3,240件の閲覧回数
jzhang1
Contributor II

Thanks!!!

GPDO[1] works! "SIUL2->GPDO[1] ^= SIUL2_GPDO_PDO_4n_MASK;"

I try to use function "PIN_DRV_TogglePins" to replace the mask(which I'm not familiar with), I found it is much easier for me to achieve the same result. 

"PINS_DRV_TogglePins(PTA,1<<4);"

Again, Thank you for your help.

0 件の賞賛
返信