Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | I2C Line following sensor - need help

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

I2C Line following sensor - need help - jordnam128 - Nov 25 22:53:31 2008

I am having trouble communicating the Line Following sensor with an
HCS12 microcontroller. The controller does have the proper transceiver
module and registers associated with it. It is able to send out the
code to the sensor but does not receive proper signal back. Here is
the code with comments. Please help if you can.

#include
#include
#define TERMINAL_TIMEOUT 100
#define IBDR _P(0xE4)
int dummy=0;
int line_sensor_data=0;
void main()
{
while(1)
{
IBFD=0x27; //baud rate=16.66 kHz,
IBCR=0xB0; //enable IIC bus, interrupt disable, master-transmit mode

IBCR |= 0x30; //sets as controller as Master, sets Tx - transmit mode
IBDR = 0x50; //sends slave address out, with write bit
while((IBSR&0x02)!=0x02){}; //waiting for transfer complete

IBSR |= 0x02; //clear IBIF flag
IBCR &= 0xEF; //sets Rx, recieve mode
while((IBSR&0x01)==0x01){}; //wait for ack.
dummy=IBDR; //dummy read

IBCR |= 0x10; //sets Tx, transmit mode
IBDR = 0x01; //sends slave internal address out
while((IBSR&0x02)!=0x02){}; //waiting for transfer complete

IBSR |= 0x02; //clear IBIF flag
IBCR &= 0xEF; //sets Rx, recieve mode
while((IBSR&0x01)==0x01){}; //wait for ack.

IBCR |= 0x12; //sets Tx - transmit mode, generate repeat cycle
IBDR = 0x51; //sends slave address out, with read bit
while((IBSR&0x02)!=0x02){}; //waiting for transfer complete

IBSR |= 0x02; //clear IBIF flag
IBCR &= 0xEF; //sets Rx, recieve mode
while((IBSR&0x01)==0x01){}; //wait for ack.
line_sensor_data=IBDR; //pull data

IBSR |=0x02; //clear the IBIF interupt flag
IBCR &= 0xDF; //generates stop by switching from master to slave
}
}
------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )