Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 8 months ago.
SPI / I2C clock defect? (frequency irregular above 20kHz)
I'm trying to get the lpc1768 SPI port (p5,p6,p7) running. I started using the example code in the Handbook section ( https://mbed.org/handbook/SPI ) but i could not establish communication with the connected device (LCD display EA DOGM162). (Additionally, i used pin p15 as DigitalOut for chipSelect and pin p16 as DigitalOut for registerSelect).
Trying to check the SPI clock frequency, i measured the ouput signal on pin p7 (sck) with a Tektronix Oscilloscope (TDS460, up to 350MHz). Using the following code, i expected to measure a constant frequency of 380 kHz on p7:
#include "mbed.h" SPI spi(p5, NC, p7); // mosi, sclk int main() { spi.format(8,3); spi.frequency(380000); while(1) { spi.write(0x00); } }
I varied the value of spi.frequency and measured the following results on pin p7 (sorry, i don't know how to make a table...):
spi.frequency(): measured frequency p7: measured amplitude p7: 10 kHz 10 kHz 4.4 V (range: 0 - 4.4 V) 20 kHz 20 kHz 3.5 V (range: 0.2 - 3.7 V) 100 kHz constant (DC) noise (level: 2 V) 380 kHz 20 kHz 0.2 V (range: 1.9 - 2.1 V) 1 MHz irregular (10-20kHz) 0.1-0.2 V (range: 2.0 - 2.2 V)
Formerly, I also couldn't get the I2C ports running because there also the clock didn't seem to work.
Question: is my mbed defect (which seems very probable to me) or did i miss to activate / declare / connect something very elementary?
1 Answer
11 years, 8 months ago.
Solved. It was a oscillator problem (bad connection). SPI communication works now. Every single write command needed to be introduced by a chipSelect=0 and closed by a chipSelect=1 signal.