Array
(
    [content] => 
    [params] => Array
        (
            [0] => /forum/threads/cannot-make-spi-communication-here.8985/
        )

    [addOns] => Array
        (
            [DL6/MLTP] => 13
            [Hampel/TimeZoneDebug] => 1000070
            [SV/ChangePostDate] => 2010200
            [SemiWiki/Newsletter] => 1000010
            [SemiWiki/WPMenu] => 1000010
            [SemiWiki/XPressExtend] => 1000010
            [ThemeHouse/XLink] => 1000970
            [ThemeHouse/XPress] => 1010570
            [XF] => 2021770
            [XFI] => 1050270
        )

    [wordpress] => /var/www/html
)

Cannot make SPI communication here

L

Lirrong

Guest
I am new to microcontrollers programming and I am trying to establish SPI communication between PIC24FV32KA301 and MS5611.<o:p></o>
After a week of searching and learning about SPI I am still not able to communicate between those two and I would appreciate if someone could help me.<o:p></o>
Am I missing something?


Code:
[COLOR=#858C93][FONT=Consolas]/* Device header file */#if defined(__XC16__)[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]<xc.h></xc.h>[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]#elif[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] defined(__C30__)[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#if defined(__PIC24E__)[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]
</p24exxxx.h>[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#elif[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] defined (__PIC24F__)||defined (__PIC24FK__)[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]
</p24fxxxx.h>[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#elif[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] defined(__PIC24H__)[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]
</p24hxxxx.h>[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#endif#endif[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]<stdint.h></stdint.h>[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]/* Includes uint16_t definition                    */#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]<stdbool.h></stdbool.h>[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]/* Includes true/false definition                  */[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]"system.h"[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]/* System funct/params, like osc/peripheral config */#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]"user.h"[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]/* User funct/params, such as InitApp              */[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]"uart1.h"[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]#include[/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]<libpic30.h></libpic30.h>[/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]// __delayXXX() functions macros defined here[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]/******************************************************************************//* Global Variable Declaration                                                *//******************************************************************************/[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]/* i.e. uint16_t <variable_name>; */</variable_name>[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]/******************************************************************************//* Main Program                                                               *//******************************************************************************/[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]void[/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]SPIinit[/FONT][/COLOR][COLOR=#303336][FONT=Consolas](){[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//Master mode, 8bits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1CON1bits.MSTEN = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1CON1bits.MODE16 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//8bit[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1CON1bits.DISSCK = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//SPI mode 0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1CON1bits.CKP = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1CON1bits.CKE = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//1:1 prescale[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//SPI1CON1bits.SPRE = 0b111;[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//SPI1CON1bits.PPRE = 0b11;[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//Enable SPI operation[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1STATbits.SPIROV = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1STATbits.SPIEN = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];}[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]char[/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#101094][FONT=Consolas]char[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] command){[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]unsigned[/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]int[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] buffer;[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//wait until the device is available[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]while[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]( SPI1STATbits.SPITBF);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]// Initiate the exchange[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    SPI1BUF = command;[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]// Wait for the exchange to complete (or handle things via an ISR)[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]while[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]( !SPI1STATbits.SPIRBF);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//Read from buffer[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    buffer = SPI1BUF;[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//return first byte[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]return[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] buffer & [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0xff[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];}[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]int16_t[/FONT][/COLOR][COLOR=#303336][FONT=Consolas] main([/FONT][/COLOR][COLOR=#101094][FONT=Consolas]void[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]){[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]/* Configure the oscillator for the device */[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]ConfigureOscillator[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]();[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]/* Initialize IO ports and peripherals */[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]InitApp[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]();[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//OSCCON = 0x11C0;   //Use primary, no divide FCY = 10Mhz/2 = 5Mhz[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    OSCCON = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x11C0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    CLKDIV = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x0000[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];     [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//do not divide[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    ANSELA = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x0000[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    ANSELB = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x0000[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//UART[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB2 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB7 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//SPI[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB12 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//SCK[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB13 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//SDO[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB14 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//SDI[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]TRISBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].TRISB15 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//CSB[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]LATBbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].LATB15 = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]; [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//CSB[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//Disable Watch Dog Timer[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]RCONbits[/FONT][/COLOR][COLOR=#303336][FONT=Consolas].SWDTEN = [/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0[/FONT][/COLOR][COLOR=#303336][FONT=Consolas];[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    UART1Init([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]12[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);   [/FONT][/COLOR][COLOR=#858C93][FONT=Consolas]//Initiate UART1 to 19200 at 8MHz OSCI[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]SPIinit[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]();[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    __delay_ms([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1000[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x1E[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    __delay_ms([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]3[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//pressure command[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x40[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    __delay_ms([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]9[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]);[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#858C93][FONT=Consolas]//read[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    UART1PutChar([/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x00[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]));[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    UART1PutChar([/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x00[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]));[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]    UART1PutChar([/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]SPIsend[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]0x00[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]));[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#101094][FONT=Consolas]while[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]([/FONT][/COLOR][COLOR=#7D2727][FONT=Consolas]1[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]){[/FONT][/COLOR][COLOR=#303336][FONT=Consolas]<o:p></o:p>[/FONT][/COLOR]
[COLOR=#303336][FONT=Consolas]<o:p> </o:p>[/FONT][/COLOR]
[COLOR=#242729][FONT=Verdana][COLOR=#303336][FONT=Consolas]    }}[/FONT][/COLOR][/FONT][/COLOR]



I am using UART1PutChar to send results back to my computer and I am always getting the response 0xFF from MS5611, but if I connect SDO and SDI on board I get back the same data I am sending to MS5611 which means my code works but sensor(MS5611) is dead?<o:p></o>
 
Back
Top