Using SynchroMaster and PWM Components for MC13213

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using SynchroMaster and PWM Components for MC13213

1,672 Views
pinakinmunot
Contributor I

Hello all !

I have designed a custom hardware for MC13213, which uses a Grounded Plane, Inverted F Antenna.

My application requires:

- Data transfer using the inbuilt Modem.

- Using PWM channels of Timer PWM Module 2, from MC13213.

- For Data transmission, I tried using the SynchroMaster component for SPI, that is present in ProcessorExpert.

  The resulting code works well in Debug Mode and I can see the transmitted data in the SPI output Buffer in Chip View.

- When I Flash it on my Hardware, how can I check whether the code is running and modem is active ?


- I tried using PWM Components on the required pins of hardware. However, if I set the initial polarity of the component as high or low, the code simulates properly, with toggling of the pin value (in Chip View).

- But, when I flashed it onto my hardware, the corresponding pin remains tied to the initial value that is set in software.

There is no toggling of the pin. So no PWM can be observed.


Kindly let me know how to address the above issues.

I have been stuck at this point since the last few days and it will be very helpful if they are be resolved.


Thanks in Advance !

- Pinakin.

0 Kudos
12 Replies

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

     Hello Pinakin,

     I run a test of the PWM component on a MC13213 SRB evaluation board and it worked fine, I could see the PWM output on a logical analyzer. If you could send me your component settings I can test again with those settings to make sure they are ok. Since I don't know details about your hardware I can't give you much useful advice on what could be wrong. Can you connect to it with the debugger to confirm that the initialization code has executed, and to check the state of the registers? Or you could toggle a GPIO pin after Processor Expert initialization function, PE_low_level_init(), to confirm that the function has completed.

     Regarding the SPI-Modem communication, you can monitor the PTE2-PTE5 pins if your hardware offers access to them. Unfortunately I could not access them on my board so I could not test this component.

     Best regards,

     Cristian

1,191 Views
pinakinmunot
Contributor I

Hello cristianzamfirescu !

Thanks for replying !

I wrote a code using Processor Expert Component for Byte Control, on Port A.

First I set the value of Port A as 0xFF. That gave a logic high (3.3V) output signal.

Then I wrote another code, setting the value as 0x00 for Port A, which gave a logic low (0V) output signal.

When I toggled the value of that Byte component, in a single code, the toggling did not happen.

How do I solve this issue ?

My hardware is the same layout as the Freescale Reference design 1321x_IPB_RevA which I got in the Reference Designs Section of Freescale Website.

I have used the same design, only the circuit layout is different and I have used locally available, but compatible components.

I will execute the code again today, and will let you know, about what happens after PE_low_level_init().

I use the PnE Multilink Universal Programmer, so will try to connect it to device in Debugger mode.

Meanwhile, if I am missing some settings, could you please let me know ?

I will check all my component configuration settings again and try executing it again.

Regards,

- Pinakin.

0 Kudos

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

     Hello Pinakin,

     You can use component BitIO instead of ByteIO to control a single pin instead of a whole port. You can also use multiple BitIO components to generate different signals at multiple checkpoints, for example toggle one pin at the start of Main function, another one after Processor Expert initialization, and so on.

     If something as basic as toggling a pin does not work, then my best guess is that there is some deeper problem, the code is not running, it gets stuck in an ISR, or something like this. You should connect with the debugger to check the state of the code.

     Best regards,

     Cristian

0 Kudos

1,191 Views
pinakinmunot
Contributor I

Hello cristianzamfirescu !

I am sorry for replying so late. I was busy in verifying my entire hardware circuit.

I checked the use of ByteIO component in ProcessorExpert. I have named the ByteIO component as PORTA since I am controlling Port A of MC13213. I am able to toggle pins with the following code, written in area for user code in the source processorexpert.c :

for(;;)

{

PORTA_PutVal(0xFF);

for(i=0;i<10;i++);

PORTA_PutVal(0x00);

for(i=0;i<10;i++);

}

This code is working on my hardware . My problem is about use of the PWM component.

I am using 4 PWM channels, all from the TPM2.

I configured all the channels for a 10ms period and 5 ms duty PWM.

The initial polarity of all channels was set as LOW.

What code is to be written in the area for user code in the source processorexpert.c to start generation of PWM output ?

Please do let me know if I am missing something or some settings.

Thanks in advance !

Pinakin.

0 Kudos

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

     Hello Pinakin,

     The settings are good, I tried them in a test and it worked. What I did is create a new MC13213 project with PEx support, add 4 PWM components, set "PWM or PPG device" property to TPM21, TPM22, TPM23 and TPM24 respectively, and set "Period" to 10ms and "Starting pulse width" to 5. I changed no other property from the default value and I wrote no code. The PWM is started by PEx initialization code if property "Enable in init code" is set to yes, so no user code is required. I run the test and saw the PWM signal on pins PTD4, PTD5, PTD6 and PTD7 with a logical analyzer.

     Best regards,
     Cristian

0 Kudos

1,191 Views
pinakinmunot
Contributor I

Hello Cristian !

As I said in my last reply, I tried initializing the PWM and the SynchroMaster (SM) components again, in main().

I am observing the output pins, on a Digital Storage Oscilloscope (DSO) using a single strand wire, connected to the respective pin.

I have brought out all the pins of TPM2 Module, using simple pins (single pin connectors).

There is no output obtained on the DSO, even after calling Init functions in main().


- I am using a 16 MHz crystal for my board and have done suitable settings in PEx

- I have designed and implemented a push-pull circuit,  on my board. I am using it for providing more output power. Each PWM channel drives an individual push-pull circuit. The Push-Pull circuit has npn & pnp BJTs as input stage & MOSFET as output stage. This circuit is verified on Simulation as well as Hardware.

*I do not know the reason why this is not working ! Could you please help ?

*As I said previously, I am not getting any output even from SynchroMaster component. I wish to transmit a few simple data strings, from one MC13213 to another. Can you suggest some solution for this ?

Awaiting your reply !

Thanks in Advance !

- Pinakin.

0 Kudos

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

     Hello Pinakin,

     There is no need to call PWM_Init() functions again in main(), they are already called in Processor Expert initialization code. You can check that in generated code, file cpu.c, function PE_low_level_init().

     Could you try to use BitIO components to toggle the PWM output pins, PTD4 - PTD7? I understand that you did a similar test on port A, but perhaps it would be better to test the exact pins that are used in the PWM test and confirm that you can see them change. This test should be a different project from the one using PWM components, because Processor Expert will not allow you to have a PWM component and a BitIO component with the same output pin.

     Another thing you could try is to connect with the debugger, stop the code after the Processor Expert initialization function, PE_low_level_init(), check the state of the PWM registers and confirm that all settings are as expected.

     Unfortunately I don't know what other advice to give you, since I can't reproduce the problem. On my board the PWM worked with almost no effort, with the steps described in my previous message.

     Regarding SynchroMaster component, Processor Expert has no support for the on-chip modem, only the SPI module which is connected to it. To check the functionality of the SPI, you can monitor the PTE2-PTE5 test pins if your hardware offers access to them. Unfortunately my board does not, so I could not test it myself. But the protocol of communicating with the modem is not covered by Processor Expert, so I have no way to test the modem.

Best regards,

Cristian

0 Kudos

1,191 Views
pinakinmunot
Contributor I

Hello Cristian !

I used a BitIO component on each of the four TPM2 PWM channels and tried toggling those bits. That code worked.

I observed the toggling of the pins distinctly.

However, what I could not understand is that the code that I write in User Code Section starts executing after a time delay, mostly of around 2 minutes.

I have also written a code for a 16x2 LCD and I am facing the same problem, that is, related to the delay in start of execution.

After the initial delay, both the codes run fine.

Could you please help me out in this regard ? What should I do to minimize/eliminate this starting delay ?

Awaiting your reply.

Thanks in advance !

- Pinakin

0 Kudos

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

     Hello Pinakin,

     I have never heard of such a big delay, my code downloads in a few seconds and runs immediately.

     Could you try to connect with the debugger and see what the cpu is doing during this time?

     What version of CodeWarrior are you using? I am using CW 10.5.

     Best regards,

     Cristian

0 Kudos

1,191 Views
pinakinmunot
Contributor I

Hello Cristian !

I'm very sorry to have not replied to your post earlier.

I tried connecting the USB Multilink Universal to my hardware in the Debug Mode.

However, in for quite some time, it gave me a notification that connection with the hardware is lost.

I am using CodeWarrior 10.4


I've tried to connect it again & again, using various settings. But it does not help me see what is currently going on in the hardware.

As I said before, the delay is only initial. Once execution starts, the entire code runs fine.

Could you please let me know how to connect the debugger and what settings to make ?

Also, what should I look for, once the Debugger starts ?

How will I come to know what the CPU is doing currently ?

Thanks in advance !

Yours Sincerely,

Pinakin.

0 Kudos

1,191 Views
cristianzamfire
NXP Employee
NXP Employee

   Hello Pinakin,

   I used the default settings and had no problems connecting. I only get connection lost message when I reset the board from the reset button. Then I can chose to reconnect. I don't know why you get disconnected, it may be the same issue that causes the initial delay. Can you reconnect after the code starts executing?

   If you can connect with the debugger you can check the location of the program counter to see what code the cpu is running, for example if it is inside a loop. I have no idea what might be causing such a big delay so unfortunately I can't be more specific than this.

   Best regards,

   Cristian

0 Kudos

1,191 Views
pinakinmunot
Contributor I

Hello cristianzamfirescu !

I'm sorry again, for the delay in replying.

I tried working on the settings again & again, so that the PWM is obtained.


However, it did not work !

Could you please recommend some remedy for my problem ?

I think there is some problem in the PEx initialization.

** I tried using the SynchroMaster component as well, but that too did not work. That is why I think that there might be some problem in PEx Init code.**


As I said before, simple pin toggling is working on my hardware.

The pin toggling code, involved writing the code that I have mentioned previously, in the User Code section.

I think calling the PWM Init functions for the respective 4 PWM components again, in the User Code will work.

I will try calling PWM1_Init() and similar Init functions for the other 3 PWM components and also set the duty and period in the User Code section.

I will get back to you with what happens as soon as possible !

Please suggest some possible remedy !

Awaiting your reply !

Yours Thankfully,

Pinakin

0 Kudos