AnsweredAssumed Answered

MQX with SPI no activity on CS, SCLK, SDOUT

Question asked by shenlung on Jun 21, 2013

Good day I'm using spi0 on portD pins. I've configured the MK60N512LL100 in PE. I get no activity on any SPI lines looking with a logic analyzer.  I'm not sure what I'm doing wrong so any help appreceiated. I attache the files I think are relevant to the BSP, The function below gets the data.

 

void GetTemps(){
    byte AddrByte = PACK1;
    char buffer[10];
    byte command[2]={0x0e,0xea};
    int i;
    FILE *spifd;
    setPECbyte(AddrByte);

 

   
    printf("Pack1 Address PEC byte: %x, %x\n", AddrByte, PECbyte);
    printf("Temp Command %x %x\n", command[0], command[1]);
    if( (spifd = fopen("ispi0:1", (pointer)(SPI_CLK_POL_PHA_MODE3))) != MQX_OK)  /* CS0 on bus spi0*/
            printf("Error opening SPI0\n");
        else{
            printf("Opened SPI0\n");
        }
   
    write( spifd, &AddrByte, 1);
    write( spifd, &PECbyte, 1);
    write( spifd, command, 2);
    for( i=0; i<5; i++){
        read(spifd, &buffer[i], 1);
        printf("Packet %d: %x\n", i, buffer[i]);
    }
    read(spifd, &PECpacketREAD, 1);
    fflush(spifd);
    fclose(spifd);
    setPECpacket(5);
    if( PECpacketREAD != PECpacket){
        printf("BAD B%i TPEC %2x<>%2x\n", AddrByte, PECpacketREAD, PECpacket);

    }

}

Original Attachment has been moved to: init_spi.c.zip

Original Attachment has been moved to: user_config.h.zip

Original Attachment has been moved to: ProcessorExpert.pe.zip

Original Attachment has been moved to: init_bsp.c.zip

Original Attachment has been moved to: init_gpio.c.zip

Outcomes