How could I output 50MHz square waveform by using FRDM-K64F?

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

How could I output 50MHz square waveform by using FRDM-K64F?

Jump to solution
2,543 Views
gloria
Contributor III

Hi, guys. I am a newer about ARM processor. How could I output 50MHz square waveform by using FRDM-K64F since the maximum frequency of CPU is 120MHz. Thanks in advance!

Labels (1)
1 Solution
1,643 Views
isaacavila
NXP Employee
NXP Employee

Hi Gloria

Actually, reference is square wave but we both see more like a senoidal due to pin's speed on toggling its state.

(And of course, due to oscilloscope's sampling frequency).

This speed is limited and when toggling pin's state it takes time to reach the opposite state and that is why we saw like a sine-wave (it could be more like a triangle-wave)

Regards,

Isaac

View solution in original post

0 Kudos
10 Replies
1,643 Views
DavidS
NXP Employee
NXP Employee

Hi Gloria,

Using the FRDM-K64F Freedom board with KDS_3.0 and KSDK_1.2.0 and the gpio_example_frdmk64f as a test project I did the following to get a 50MHz clock out on the PTC3 (I used o-scope on pin J1 pin 16 header and ground on J2 pin 14).

Added to main.c (file attached too....look for "//DES" to find modifications:

#include "fsl_sim_hal.h"

In main function add:

    PORT_HAL_SetMuxMode(PORTC, 3U, kPortMuxAlt5);//DES PTC3 = CLKOUT
    PORT_HAL_SetDriveStrengthMode(PORTC, 3U, kPortHighDriveStrength);//DES high drive strength
    CLOCK_HAL_SetClkOutSel(SIM, OSCERCLK0);//DES CLKOUTSEL=0x4=OSCERCLK0

Regards,

David

1,643 Views
gloria
Contributor III

Hi David, many thanks for your help. I have tested the signal by o-scope. The output voltage is so small from J1 Pin16. Is there any way to change the output voltage from the pin?

0 Kudos
1,643 Views
isaacavila
NXP Employee
NXP Employee

Hi Qingyuan

Previous project uses internal reference clock to be out on PTC3 pin, so this signal could not be amplified or modified to change its voltage level.

In this case, there is not possible to get a 50MHz output signal, for example, through a timer's output due these peripherals use bus clock as their reference clock and due bus clock is up to 60 MHz. maximum output frequency could be 30MHz (60MHz / 2).

If you use this signal (60MHz maximum, setting core clock to work at 120MHz), you can toogle an output every 1-step counter and after 2 cycles, your signal returns to its initial state, resulting in a 30MHz output frequency.

pastedImage_0.png

I hope this can help

Best Regards,

Isaac

1,643 Views
gloria
Contributor III

Hi Avlia,

Thank you very much. Your advise is soooooo helpful.

Do you know whether the internal reference clock used in previou project is a sin wave or a square wave. Because I use a 100MHz oscillscope and what I see in the oscilliscope from PTC3 is more like sin wave. I am not sure if it is caused by oscillscope. Many thanks!

0 Kudos
1,643 Views
isaacavila
NXP Employee
NXP Employee

Hi Gloria,

I also used a 100 MHz Oscilloscope so I had same results as yours. It is more like a sin wave.

Regards,

Isaac

0 Kudos
1,643 Views
gloria
Contributor III

Hi Isaac,

Do you mean the internal reference clock is actually a sin wave instead of square wave? Sorry for my so limited knowledge of ARM processor.

Thanks a lot!

Best Regards,

Gloria

0 Kudos
1,644 Views
isaacavila
NXP Employee
NXP Employee

Hi Gloria

Actually, reference is square wave but we both see more like a senoidal due to pin's speed on toggling its state.

(And of course, due to oscilloscope's sampling frequency).

This speed is limited and when toggling pin's state it takes time to reach the opposite state and that is why we saw like a sine-wave (it could be more like a triangle-wave)

Regards,

Isaac

0 Kudos
1,643 Views
gloria
Contributor III

Hi Isaac,

I get confused about the waveform.

Capture.PNG

Why the lowest voltage of the waveform is a negative value and the waveform is not symmetric as normal?

Many thanks for your help!

Best Regards,

Qingyuan Meng

0 Kudos
1,643 Views
egoodii
Senior Contributor III

I think you will have to agree that a 100MHz scope-bandwidth is only twice the 'frequency of interest', so how could you expect to see anything more than the fundamental, the sine-wave of 50MHz?  As the 'sum of odd harmonics', you would need at LEAST the 3rd (150MHz) and 5th (250MHz) harmonics to pass-thru 'relatively undiminished' to start to look square.  And working this close to the 'max range', the scope is probably also 'filling in' a sine-wave from the points it CAN read, hence generating a waveform that exceeds the rails.  Of course there I am ASSUMING that this 50MHz is NOT driving an unterminated trace, which would of course add its own 'ringing' to the situation!  Kinetis silicon is certainly capable of clean, fast edges -- see my 500MHz-scope picture in:

Confirming K22F Clock Frequency

Although not the 'square wave' I expected in that shot, I got said square-wave with 'better code', showing a sequence of 10ns high and low intervals.  The point is that signal rise/fall-time can be about 5ns.

1st, 3rd & 5th make 'red' waveform:

Note also how the 'pure sine wave' (green) is at a higher peak-to-peak than the 'final' +/-1 'squared off' wave.

1,643 Views
gloria
Contributor III

Dear Isaac,

Thank you for your kindly help so so much! You help me a lot!

Best Regards,

Gloria

0 Kudos