MQX with SPI no activity on CS, SCLK, SDOUT

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MQX with SPI no activity on CS, SCLK, SDOUT

1,316 次查看
shenlung
Contributor II

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

标记 (4)
0 项奖励
回复
1 回复

989 次查看
timias
Contributor IV

You are probably going to need to modify the BSP files and reconfigure the pins it uses. I am about 90% sure that SPI0 lines in MQX are configured to use PortC as the default. You will need to change the Port PCR registers in the BSP to point to the new port.