hello,
i'm trying to get a simple SPI code working, and when i measure the SCK pin (PB1) with the oscilloscope i get a frequency of 15MHz, with a Vp-p of ~68mV... I would expect a freq of 7.3728MHz/64=115.2kHz at that pin. What am i missing?
Thank you!
- Eric
#define F_CPU 7372800UL #include#include #include #include #include #include #include #include #include #include /*SPI configuration*/ #define DD_SS DDB0 #define DD_SCK DDB1 #define DD_MOSI DDB2 #define DD_MISO DDB3 #define DDR_SPI DDRB #define SPI_PORT PORTB void SPI_MasterInit(void) { //Set MOSI, SCK, CS output, all others input DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK)|(1<<DD_SS); // Enable SPI, Master, set clock rate fck/64 --> 115.2kHz SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1); } void SPI_MasterTx(char cData) { // Start transmission SPDR = cData; // Wait for transmission complete while(!(SPSR & (1<<SPIF))); } int main(void) { SPI_MasterInit(); while(1) { // Activate the CS pin - LOW SPI_PORT &= ~(1<<DD_SS); SPI_MasterTx('A'); // Deactivate CS pin - HIGH SPI_PORT |= (1<<DD_SS); _delay_ms(3000); } }
EDIT - there is no slave connected at the moment. it's just the atmega64