This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

xc164cs - spi

hi i configured xc164cs-spi using the following code. but the clk is not coming in the sclk pin. can anybody help
SSC0_CON_EN=0;
SSC_BR = 13 ;//(40000000/2*1000000)-1
SSC0_CON=0xc037;
P3.13=1;
ALTSELP3.13=1;
DP3.13=1;

Parents
  • Hello,

    Here is a checklist:

    0. Your code does not show you try to write to SPI TX register (e.g., along with busy bit polling) - try to do it and see what happens. As per continuous transfer, a special care should be taken...
    1. Try to program MTSR, MRST, SCLK pins' state, direction and push/pull mode explicitly
    2. Make sure you use correct header file with proper MCU register definitions
    3. Using debugger, verify that the code generated (ASM) is what you expected
    4. If you MCU is connected to an external SPI device, try to disconnect it / desolder its pins and verify if you have SPI signals on MCU pins
    5. Check if you have only one master on the bus
    6. Do not you have a PEC channel assosiated with the SPI? - Stop it first if you have

    Initialization of the SCLK pin requires attention to avoid clock transitions you do not want to have (may disturb other receivers). Read more details in user manual, here is the summary:
    - select the clock idle level
    - load the port output latch with the desired clock idle level
    - switch pin to output
    - enable SPI
    - depending on clock polarity (if idle clock line is low), enable alternate data output

    -- Nikolay.

Reply
  • Hello,

    Here is a checklist:

    0. Your code does not show you try to write to SPI TX register (e.g., along with busy bit polling) - try to do it and see what happens. As per continuous transfer, a special care should be taken...
    1. Try to program MTSR, MRST, SCLK pins' state, direction and push/pull mode explicitly
    2. Make sure you use correct header file with proper MCU register definitions
    3. Using debugger, verify that the code generated (ASM) is what you expected
    4. If you MCU is connected to an external SPI device, try to disconnect it / desolder its pins and verify if you have SPI signals on MCU pins
    5. Check if you have only one master on the bus
    6. Do not you have a PEC channel assosiated with the SPI? - Stop it first if you have

    Initialization of the SCLK pin requires attention to avoid clock transitions you do not want to have (may disturb other receivers). Read more details in user manual, here is the summary:
    - select the clock idle level
    - load the port output latch with the desired clock idle level
    - switch pin to output
    - enable SPI
    - depending on clock polarity (if idle clock line is low), enable alternate data output

    -- Nikolay.

Children
  • hi i have written like this SSC0_CON = 0x4037 //en=0; SSC0_CON_EN = 1; SSC0_BR = 0x0013;//(F_CPU /(SPI_BAUDRATE * 2L) - 1); ALTSEL0P3_P8 = 1; ALTSEL0P3_P9 = 1; ALTSEL0P3_P13 = 1;

    DP3_P8 = 0; // MISO Input DP3_P9 = 1; // MOSI Output DP3_P13 = 1; // Clock Output

    P3_P8 = 0; P3_P9 = 1; P3_P13 = 1;

    still im not getting the clock. so i make my own clock in sclk pin and put data in transmit buffer and enable ssc it will trasmit on the transmit pin master? or if i make my own clock on the sclk pin i only have to feed data directly to transmit line?