AnsweredAssumed Answered

Using SPI port with MC1322x ....what's wrong?

Question asked by Marco Stevanoni on May 5, 2010
Latest reply on May 8, 2010 by Marco Stevanoni

I'm trying to use the MC1322x spi port

 

void SPI_Init()
{
uint32_t Command=0xff;
  //CLK
  Gpio_SetPinFunction(gGpioPin7_c, gGpioNormalMode_c);
  Gpio_SetPinDir(gGpioPin7_c, gGpioDirOut_c);
  Gpio_SetPinData(gGpioPin7_c, gGpioPinStateLow_c);
 
  //MOSI
  Gpio_SetPinFunction(gGpioPin6_c, gGpioNormalMode_c);
  Gpio_SetPinDir(gGpioPin6_c, gGpioDirOut_c);
  Gpio_SetPinData(gGpioPin6_c, gGpioPinStateLow_c);
 
  //MISO
  Gpio_SetPinFunction(gGpioPin5_c, gGpioAlternate1Mode_c);
  Gpio_SetPinDir(gGpioPin5_c, gGpioDirIn_c);
  //Gpio_SetPinData(gGpioPin5_c, gGpioPinStateLow_c);
 
  //SS
  Gpio_SetPinFunction(gGpioPin4_c, gGpioNormalMode_c);
  Gpio_SetPinDir(gGpioPin4_c, gGpioDirOut_c);
  Gpio_SetPinData(gGpioPin4_c, gGpioPinStateHigh_c);

  pConfig.Setup.Bits.SsSetup       = ConfigSsSetupMasterHigh;
  pConfig.Setup.Bits.SsDelay       = ConfigSsDelay1Clk;
  pConfig.Setup.Bits.SdoInactive   = ConfigSdoInactiveZ;
  pConfig.Setup.Bits.ClockFreq     = ConfigClockFreqDiv256;
  pConfig.Setup.Bits.Mode          = ConfigModeMaster;
  pConfig.Setup.Bits.S3Wire        = ConfigS3WireInactive;
  pConfig.Setup.Bits.ClockPol      = ConfigClockPolPositive;
  pConfig.Setup.Bits.ClockPhase    = ConfigClockPhase1stEdge;
  pConfig.ClkCtrl.Bits.DataCount   = 8;
  pConfig.ClkCtrl.Bits.ClockCount  = 8;

  ret = SPI_Open();

  ret = SPI_SetConfig(&pConfig);
 
  //SPI_SetCallback();
 
  while(1)
  {
    Gpio_SetPinData(gGpioPin4_c, gGpioPinStateLow_c);
    ret = SPI_SetTxAsync(Command);
    SPI_StartAsync();
    //SPI_Abort();
    Gpio_SetPinData(gGpioPin4_c, gGpioPinStateHigh_c);
    ret = SPI_GetStatus();
  }

 

What's wrong?

Outcomes