Richard Smith

help with spi function - QG8

Discussion created by Richard Smith on Feb 4, 2008
Latest reply on Sep 16, 2010 by juan carlos
Hello
im very new to freescale and microcontrollers as a whole and im trying to use one to receive data from an EEPROM chip connected to the SPI port my code is very simple and im using polling rather than interrupts but is not working
 
[code]
PTBD_PTBD5 = 0;   /* chip select low */
SPID = 0x03;    /* send read instruction to memory */
while ((SPIS & 0x20) == 0) ;   /* Wait for instruction byte to be sent */
SPID = 0;                    /* provide first read address */
while ((SPIS & 0x20) == 0) ;   /* wait for address byte to be sent */
 SPIC1 = 0x46;        /* set spi as slave to receive data  */
for (memorycounter =0 ;memorycounter < 50000; memorycounter ++)
{
  while ((SPIS & 0x80) == 0) ;   /* Wait for memory data byte to be sent back */
  memorydata = SPID;
  SCID = memorydata;
  while ((SCIS1 & 0x80) == 0) ;   /* Memory data out serially to RS232/computer */
}
PTBD_PTBD5 = 1;   /* chip select high */
 
[/code]
i basically just want to read the first 50,000 bytes of memory from EEPROM, just wondering if anything in my code jump out at anyone as being particularly wrong? before i get into the nity gritty stuff.
 
Much Appreciated
Rick
 
sorry forgot to mention the micro is a hcs08 QG8
and in the debug mode my code seems to send the instruction byte ok ( i think) but then then gets stuck sending the address to the EEPROM ( code does not reach any instructions after this one) so maybe im not reseting the status register properly or something?



Message Edited by rick123 on 2008-02-04 06:28 PM

 

Added p/n to subject.



Message Edited by NLFSJ on 2008-02-05 07:42 AM

Outcomes