5
\$\begingroup\$

I am using a Pic18F45K40 to control an ST7590 power line networking chip which requires an 8MHz clock signal to function. I read the datasheet and it looks like a 16MHz signal can be generated from the 64MHz microchip.

I set up the Reference Clock Output Module as follows:

#pragma config CLKOUTEN = ON

and

#define oCLK_INIT()      CLKRCLKbits.CLK=1; \
                         CLKRCONbits.EN=0;  \
                         CLKRCONbits.DC=2;  \
                         CLKRCONbits.DIV=3; \
                         SCANTRIGbits.TSEL=1;
                         //OSCCON1bits.NOSC=6;
#define oCLK_EN_ON()       CLKRCONbits.EN=1;

and used PPS to pin RB4 by setting

  RB4PPS=0b10100;        /* B4=CLKR 8MHz      */ \

I do get an 8MHz signal out but it looks like this:

enter image description here

This is more sinusoidal than square and might be the reason why I am not able to talk to the ST7590 chip via UART. Can anyone explain what is happening?

EDIT: Result of changing slew rate.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Do you mean PIC18F45K40? \$\endgroup\$ – MIL-SPEC Jun 18 '18 at 8:06
  • \$\begingroup\$ Could it be that the signal is degraded by the time it get to the oscilloscope inputs? E.g. by capacitance and/or inductance in the wires? \$\endgroup\$ – Andrew Morton Jun 18 '18 at 8:07
  • \$\begingroup\$ Yes, it is PIC18F45K40. It is an 8MHz signal, I don't think the length of the oscilloscope cable would change the signal like this. \$\endgroup\$ – Gareth T. Jun 18 '18 at 8:18
  • \$\begingroup\$ I see you have made progress, but what is the bandwidth of your oscilloscope? If you want it to accurately represent a square wave, the odd harmonics (3x8MHz, 5x8MHz, 7x8MHz etc) need to be within the 'scope bandwidth. For example a 20MHz 'scope (or scope probe) would show an 8MHz square wave looking like a sine wave, and you'd really want 80MHz or more if you are wanting to look at signal integrity of a square wave at 8MHz. \$\endgroup\$ – rolinger Jun 18 '18 at 13:39
7
\$\begingroup\$

Two possibilities - Stray capacitance or slew rate control.

If you were working on breadboards, I would think it to be unwanted capacitance between the pin strips but due to the package of the STmicro device, I believe you are working with proper PCBs.

That leads to the other possibility - the PIC is limiting slew rates on the port. This is done to reduce EMC from fast switching "bouncing", so the slew rates of the transistors are slowed to create a nice gradient. Works great under 1MHz but you need to be wary of it at 8MHz.

See page 244 for directions to wiping the SLRCONx registers to prevent or reduce slew rate limiting.

15.2.5 Slew Rate Control
The SLRCONx register controls the slew rate option for each port pin. Slew rate for each port pin can be
controlled independently. When an SLRCONx bit is set, the corresponding port pin drive is slew rate
limited. When an SLRCONx bit is cleared, The corresponding port pin drive slews at the maximum rate
possible.
\$\endgroup\$
  • \$\begingroup\$ Oh wow that did have an effect. \$\endgroup\$ – Gareth T. Jun 18 '18 at 8:54
  • \$\begingroup\$ Did it have the intended effect? Completely wiping the register may induce unwanted ringing to the signal, so you may want to actually just speed up the slew rate. \$\endgroup\$ – MIL-SPEC Jun 18 '18 at 8:57
  • \$\begingroup\$ I have added the response to the question. Thnka you, I will do the next lot of testing shortly. \$\endgroup\$ – Gareth T. Jun 18 '18 at 9:03
  • \$\begingroup\$ Assuming you wiped the register completely, this is now what I would expect when seeing stray capacitance i.e. the ramped rising edge, sharp falling edge with a ramp at the bottom. \$\endgroup\$ – MIL-SPEC Jun 18 '18 at 9:04
  • 1
    \$\begingroup\$ I agree with its current shape and as Xin on the ST7590 is an analogue pin to it will read the appropriate High and low. I only cleaned the pin connected to the SLRCONB. so the rest of the register will remain active. I still can not get a response from the ST7590 but it is for another reason and not the clock. Thank you. I will post another question shortly. \$\endgroup\$ – Gareth T. Jun 18 '18 at 9:15
1
\$\begingroup\$

An ideal square wave signal does not exist. You will always have a certain rise and fall time in your signal. The higher your frequency is, the larger gets the relative amount of rise and fall time compared to your total on and off time respectively. What you suffer from is on one hand the parasitic properties of your path and the internal wiring of the pin including ESD protection and capacitance to ground.

An external oscillator also doesn't produce a clean square wave signal but rather one looking like your scope print, but that's not a problem as you usualy have edge detection function on your clock inputs.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.