David Nguyen

9S12C128 SPI problem - SCK: not outputting a clock signal

Discussion created by David Nguyen on Mar 9, 2009
Latest reply on Mar 16, 2009 by Stéphane Loret

I am using CodeWarrior to program the C128 and the following code to initialize the SPI and make the MCU the master:


void DAC_Init(void)


    DDRM |= 0x38;  //PM5 = SPI clock out; PM4 = SPI master out

    PTM |= 0x08;    //PM3 = 1

    SPICR1 = 0x50; //Enable SPI and make master

    SPICR2 = 0x00; //Normal mode

    SPIBR = 0x07;   //93.75 kHz clock on PLL



I measured the SCK pin with an oscilloscope and got a flat line.  I tested the hardware and found that the SPI ports were working fine.  Do you guys think that there is something wrong with the code above or that the MCU could be fried?



Do you guys think this will work?:


I was thinking of changing the MCU to slave mode and then use the PWM to create a clock for the SCK pin as well as the device I was going to connect the SCK pin to.  So technically, the MCU and the device will both be in slave mode, just that the MCU will send out a signal over the MISO pin.  The device that I will be connecting to is a DAC.