Forums

LPC2138 with CS8900A

Started by ravindra_lpc July 26, 2006
Hi ,

I m using LPC2138 with CS8900A module.for this I hav used only
following pins of LPC2138 to be connected to CS8900A.

LPC2138 CS8900A
1-P0.16 to P0.23 connected with SD0 to SD7

2- P0.4 to P0.7 connected with SA0 to SA3

3- P0.12 & P0.13 connected with /IOR & /IOW

4-CS8900A 's pin AEN grounded , IRQ0 open ,Vcc 5 V & one GND pin.

means only 18 connections with it.
According to this LPC -E2124 schematic link--

"http://microcontrollershop.com/Images/lpc-e2124-sch.gif?
osCsid44eee9a556e658dfa511440b71696b"

First I just want to read the default register values of CS8900A to
check a communication with it.

for this I used the following piece of code :
/******************************************************************/
int
main(void)
{
u8_t i, arptimer;
u16_t addr[2];
unsigned int regvalue;
unsigned char str[32];
int z = 3;
VPBDIV = 0x02;
// Cclk is divided by 2 to get pclk
init_UART0();
ppp();
/* Initialize the device driver. */
cs8900a_init();
cs8900a_write(0x030A, 0x0000);
cs8900a_readtemp(0x030C,str);
putcharUART0(str[0]);
putcharUART0(';');
putcharUART0(str[1]);
putcharUART0(';');
return 0;
}
/*******************************************************************/
void
cs8900a_init(void)
{
int i;
unsigned int regvalue;
unsigned char value[2];
// Reset outputs, control lines high
IOSET0= IOR | IOW;

// No LEDs on.
// IOSET0= LED_RED | LED_YELLOW | LED_GREEN;

// Port 3 as output (all pins but RS232)
IODIR0= ~0U; // everything to output.

// Reset outputs
IOCLR0= 0xff << 16; // clear data outputs

// Reset the CS8900A
cs8900a_write(ADD_PORT, PP_SelfCTL);
cs8900a_write(DATA_PORT, POWER_ON_RESET);

// Wait until chip-reset is done
cs8900a_write(ADD_PORT, PP_SelfST);
while ((cs8900a_read(DATA_PORT) & INIT_DONE) == 0)
;
// Configure the CS8900A
for (i = 0; i < sizeof InitSeq / sizeof (TInitSeq); ++i)
{
cs8900a_write(ADD_PORT, InitSeq[i].Addr);
cs8900a_write(DATA_PORT, InitSeq[i].Data);
}
}
/******************************************************************/
void cs8900a_readtemp(unsigned int addr,unsigned char* value)
{
IODIR0 &= ~(0xff << 16); // Data port
to input(P0.16 to P0.23)

IOCLR0 = 0xf << 4; // Put
address on bus
IOSET0 = addr << 4;

delay_us(5);
IOCLR0 = IOR; // IOR-
signal low
value[0] = (IOPIN0>> 16) & 0xff; // get low
order byte from data bus
IOSET0= IOR;

IOSET0= 1 << 4; // IOR high and put
next address on bus
delay_us(5);
IOCLR0= IOR; // IOR-signal
low
// value[1] = ((IOPIN0>> 16) & 0xff); // get high
order byte from data bus
value[1] |= ((IOPIN0>> 8) & 0xff00); // get
high order byte from data bus
IOSET0= IOR; // IOR-signal
low

}
/******************************************************************/
void cs8900a_write(unsigned addr, unsigned int data)
{
IODIR0 = 0x00ff00ff ; // Data port to
output(P0.16 to P0.23)

IOCLR0 = 0xf << 4; // Put address on
bus
IOSET0 = addr << 4;

IOCLR0 = 0xff << 16; // Write low order
byte to data bus
IOSET0 = data << 16;

IOCLR0= IOW; // Toggle IOW-signal
IOSET0 = IOW;

delay_us(1);

IOCLR0 = 0xf << 4;
IOSET0 = ((addr | 1) << 4); // And put next
address on bus

IOCLR0 = 0xff << 16; // Write high
order byte to data bus
IOSET0 = data >> 8 << 16;

IOCLR0 = IOW; // Toggle IOW-
signal
IOSET0 = IOW;
}

The output in UART0 is coming mostly "00 3B 02 3B " and rarely "55
3B 02 3B"
Can anybody plz tell me how I can proceed for this.

Thanks in advance.

An Engineer's Guide to the LPC2100 Series