| Electronic Components Datasheet Search |
|
MPXM2102AS Datasheet(PDF) 489 Page - Motorola, Inc |
|
|
|||||||||||||||||||||||||||||
MPXM2102AS Datasheet(HTML) 489 Page - Motorola, Inc |
|
489 / 670 page ![]() AN1551 3–343 Motorola Sensor Device Data www.motorola.com/semiconductors SOFTWARE EXAMPLES The following example listings show how a user may communicate with the smart sensor via a master MCU. The software example shown assumes that the master MCU is an MC68HC11. Any MCU with the proper I/O functionality will operate similarly with the smart sensor system. When using parallel I/O instead of an SPI port to interface the smart sensor, the user must “bit bang” the clock and data out of the parallel I/O, so as to simulate the SPI port. As long as the timing relationships of data and clock follow those of Figure 3 (see also Table 3), the smart sensor will function properly when interfaced to a processor with a parallel type interface. In the following two code examples, the sensor unit is interfaced to the master MCU via the SPI port, and the sensor’s CS input is connected to the HC11’s Port D pin 5. This example is coded in ‘C’ for the MC68HC11: /* FIRST INITIALIZE THE I/O (INCLUDE A HEADER FILE TO INCLUDE I/O DEFINITIONS) */ void init_io(void) { PORTD = 0X29; /* SS* PD5 = 1, PD3 = 1, PD0 = 1 */ DDRD = 0X3B; /* SS* PD5 = 1, PD3 = 1, PD1 = 1, PD0 = 1 */ SPCR = 0X5E; /* ENABLE THE SPI, MAKE MCU THE MASTR, SCK = E CLK /4 */ /* I/O INITIALIZATION IS COMPLETE */ } /* WE NEED A FUNCTION TO WRITE TO AND READ FROM THE SPI */ write_spi(char data) { SPDR = data; /* WRITE THE DATA TO THE SPI DATA PORT */ while( ! (SPSR & 0x80 )); /* WAIT UNTIL DATA HAS SHIFTED OUT OF AND BACK INTO THE SPI */ return(SPDR): /* RETRIEVE THE RESULTS OF THE LAST COMMAND TO THE SENSOR AND RETURN */ } /* NOW WE NEED TO CALL THE ABOVE */ void main(void) { char rtn_data; /* rtn_data IS THE RETURNED DATA FROM THE SENSOR */ init_io(); while(1) /* JUST LOOP FOREVER */ rtn_data = write_spi(0x01); /* 0x01 IS THE COMMAND TO THE SENSOR THAT REQUESTS PRESSURE. THE VALUE IN rtn_data WILL BE IN THE RANGE OF 0..0XFF = 0..100% FULL SCALE PRESSURE THE SECOND TIME THROUGH THE LOOP. THE INITIAL TIME THROUGH THE LOOP, THE DATA RETURNED IS INDETERMINATE */ } The next example is coded in assembly for the MC68HC11: * PORT OFFSETS INTO THE I/O MAP PORTS EQU $1000 ASSUME THE I/O STARTS AT $1000 PORTD EQU $8 DDRD EQU $9 SPCR EQU $8 SPSR EQU $29 SPDR EQU $2A ORG $E000 * FIRST INITIALIZE THE I/O INITIO LDX #PORTS BASE ADDRESS OF THE I/O LDAA #$29 STAA PORTD,X SS* PD5 = 1, PD3 = 1, PD0 = 1 LDAA #$3B STAA DDRD,X SS* PD5 = 1, PD3 = 1, PD1 = 1, PD0 = 1 LDAA #$5E STAA SPCR,X ENABLE THE SPI, MAKE MCU THE MASTR, * SCK = E CLK /4 RTS I/O INITIALIZATION IS COMPLETE Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |