11 Replies Latest reply on Feb 11, 2016 9:11 AM by doedelhoch4_1549746

    SPI difficulties

    doedelhoch4_1549746

      Hey guys!

         

      I tried to get SPI working. Sadly, I have no clock and slave select also doesn't go low. I have no more ideas how to get this working :(

         

      I have the pins on the right ports and I got this code:

         
          

      /* ========================================
       *
       * Copyright YOUR COMPANY, THE YEAR
       * All Rights Reserved
       * UNPUBLISHED, LICENSED SOFTWARE.
       *
       * CONFIDENTIAL AND PROPRIETARY INFORMATION
       * WHICH IS THE PROPERTY OF your company.
       *
       * ========================================
      */
      #include <project.h>
      #include "shared_vars_switching.h"
      #include "isr.h"
      #include "defines.h"

          

      const uint16_t n_ticks_per_interval = 2000;
      const uint16_t n_ticks_zx_delay = 500;
          
      int16_t duty_cycle[2] = {1000, 0};
      int16_t enabled_channels = 1;    

          

      int16_t tick_delta[4];
      int16_t tick_channel[4];
      int16_t n_tick_events = 0;

          

      int main()
      {
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          
          /* initialize switching isr */
      //    isr_switch_Start();
      //    isr_switch_SetVector(isr_switch_handle);
      //    isr_switch_SetPriority(0);
      //    
      //    isr_zx_Start();
      //    isr_zx_SetVector(isr_zx_handle);
      //    isr_zx_SetPriority(0);
      //    
      //    tmr_switch_Start();
      //    tmr_switch_WriteCompare(UINT16_MAX);
          
          
          /* set metering mode */
          CyPins_ClearPin(meter_mmd0);
          CyPins_SetPin(meter_mmd1);
          
          /* set up SPI */
          //spi_ClearMasterInterruptSource(spi_INTR_MASTER_SPI_DONE);
          //spi_SpiSetActiveSlaveSelect(spi_SPI_SLAVE_SELECT0);
          //spi_SpiSetSlaveSelectPolarity(spi_SPI_SLAVE_SELECT0, spi_SPI_SS_ACTIVE_LOW);
          spi_Start();
          
          isr_spi_Start();
          isr_spi_SetVector(isr_spi_handle);
          isr_spi_SetPriority(3);
          
          int toggle = 0;
          CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
          while(1)
          {   
              spi_SpiUartWriteTxData(ADDR_STATUS);
              CyDelay(1000);
              toggle ^= 1;
              if(toggle){
                  CyPins_SetPin(meter_LED);
              }
              else{
                  CyPins_ClearPin(meter_LED);
              }
              /* Place your application code here. */
          }
      }

          

      /* [] END OF FILE */

         
         

      The pins for SPI are on SPI[0].

         

      Thanks for any help!!

         

      Peace Noah