SLIDE 15 February 9th, 2007 Bradford Peyton / Anoop Gojanur 15
Freescale 13213SRB
LED1 LED2 LED3 LED4 SW1 SW2 SW3 SW4
Analog/Digtal I/O
Temperature sensor Acclerometer Humidity Sensor Light Sensor **************************************************************/ SRTISC=SRTISC&~0x07; //Disable wake up timer. SPMSC2=SPMSC2&~0x03; //Enable deep sleep mode stop3. TPM1SC = 0x0F; //Timer divide by 128. (16uS timebase for 8MHz bus clock). ATD1PE=0x4C; //enable desired ADC channels (AD2,AD3, AD4, AD7 on) ATD1C=0xE1; //set prescale to 4 ATD1SC = 2; //read x-axis data on ch2 ATD1SC = 3; //read y-axis data on ch3 ATD1SC = 4; //read z-axis data on ch4 PTBDD_PTBDD6 = DDIR_INPUT //set PortB pin6 as I/P to read temperature while((ATD1SC & 0x80) != 0x80){} Temperature = (ATD1RH * 300) / 256; //Since 3V = 300 degrees = 256 count, multiply by 300/256 tx_data_buffer[4] = Temperature & 0xFF; tx_data_buffer[7] = 0x30; tx_packet.dataLength = 12; for (i=0; i<retries; i++) { u8status = MCPSDataRequest(&gsTxPacket); // transmit data}
KB_INIT_MACRO
SCITransmitStr("N:"); (void)int2string((UINT32) packet_count, App_String); SCITransmitStr(App_String); temperature = (UINT8)(MLMETEMP_R()/2); //Read the temperature reading. SCITransmitStr(" Temperature=-"); (void)int2string((UINT32) temperature, App_String); SCITransmitStr(App_String);
HyperTerminal