CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SPI Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Todd Persen
Guest







SPI Problem
PostPosted: Tue May 13, 2003 3:47 pm     Reply with quote

I'm trying to set up a simple SPI Interface, but I keep running into a weird problem. When it gets to the first spi_write, it just hangs and sends no data out. I've checked the CCS example code and other posts on the board to no avail. I even checked the wiring in case it's at the hardware level, but found nothing. I've tried checking just about everything I can think of and I'm still stumped. Any help is greatly appreciated. Thanks!

I'm using an 18LF452 at 19.6608MHz.
Here's the code:

#include <18f452.h>

#fuses HS,NOWDT,NOPROTECT
#USE DELAY(clock=19660800)
#USE RS232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)

void main(void)
{
char x;

setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64);

printf("\r\nStarting: ");

spi_write(0x02); //hangs on this line
spi_write(0x20);
spi_write(0x14);
spi_write(0x01);
spi_write(0xE0);
spi_write(0x43);

x=spi_read(0xFF);
printf("\%X ", x);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 14425
Todd Persen
Guest







SPI Problem
PostPosted: Tue May 13, 2003 3:47 pm     Reply with quote

I'm trying to set up a simple SPI Interface, but I keep running into a weird problem. When it gets to the first spi_write, it just hangs and sends no data out. I've checked the CCS example code and other posts on the board to no avail. I even checked the wiring in case it's at the hardware level, but found nothing. I've tried checking just about everything I can think of and I'm still stumped. Any help is greatly appreciated. Thanks!

I'm using an 18LF452 at 19.6608MHz.
Here's the code:

#include <18f452.h>

#fuses HS,NOWDT,NOPROTECT
#USE DELAY(clock=19660800)
#USE RS232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)

void main(void)
{
char x;

setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64);

printf("\r\nStarting: ");

spi_write(0x02); //hangs on this line
spi_write(0x20);
spi_write(0x14);
spi_write(0x01);
spi_write(0xE0);
spi_write(0x43);

x=spi_read(0xFF);
printf("\%X ", x);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 14425
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Re: SPI Problem
PostPosted: Tue May 13, 2003 7:46 pm     Reply with quote

I've always used x= spi_read( char ) since this does both the read and the write ...maybe the in bound hardware buffer has overflowed since all you do is write
___________________________
This message was ported from CCS's old forum
Original Post ID: 14430
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group