MLX90609 3轴陀螺仪传感器

时间:2014-04-26 06:44:30
【文件属性】:

文件名称:MLX90609 3轴陀螺仪传感器

文件大小:622KB

文件格式:RAR

更新时间:2014-04-26 06:44:30

MLX90609

MLX90609 //Setup the hardware UART module //============================================================= SPBRG = 51; //8MHz for 9600 inital communication baud rate //SPBRG = 129; //20MHz for 9600 inital communication baud rate TXSTA = 0b.0010.0100; //8-bit asych mode, high speed uart enabled RCSTA = 0b.1001.0000; //Serial port enable, 8-bit asych continous receive mode //============================================================= } //Read data from MLX90609 via SPI void mlx_test(void) { #define SCK PORTB.0 //SCLK This is clock input into MLX90609 #define SS PORTB.1 //SS This is chip select input - when low, the MLX is selected #define MISO PORTB.4 //MISO This is output from MLX into the PIC #define MOSI PORTB.6 //MOSI This is input into the MLX from the PIC uns16 temp; uns8 data1, data2; //0 = Output, 1 = Input TRISA = 0b.0000.0000; //Set all to outputs PORTA = 0b.0000.0000; //Set all outputs low //MISO = RB4 TRISB = 0b.0001.0000; //0 = Output, 1 = Input-RX on RB4 PORTB = 0b.0001.0000; //Set RB4 High while(1) { SS = 0; //Select MLX spi_comm(0b.1001.0100); // Read rate ADCC instruction SS = 1; //Unselext MLX delay_us(250); //Wait for MLX to take measurement SS = 0; //Select MLX spi_comm(0b.1000.0000); // Send SPI ADCR Instruction data1 = spi_comm(0x00); data2 = spi_comm(0x00); SS = 1; //Unselect MLX if (data1.7 == 0 && data1.5 == 1) { temp.high8 = data1; temp.low8 = data2; temp >>= 1; temp &= 0b.0000.0111.1111.1111;


网友评论