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 CCS Technical Support

spi question

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



Joined: 20 Sep 2004
Posts: 3

View user's profile Send private message

spi question
PostPosted: Thu Sep 23, 2004 1:00 am     Reply with quote

I am using PIC16C73 to interface SPI device. bcause the device is operatiing at 3V, i am using voltage shifter 74HCT244 in between PIC and device. I am using the following code to read and send the data to device. some times i am getting correct results, some times i am not getting for the same code if i repeat more number of times. i am not getting where the mistake is. Any suggestions please?
code is as follows
Code:

#include<16C73.H>
#fuses XT,NOWDT,NOPROTECT,PUT
#use delay(clock=4000000)

void main()

{
   static int y;


   setup_spi(spi_master|spi_l_to_h|spi_clk_div_64);
   //setup_spi(spi_master);
   delay_ms(10);

   while(1){
      spi_write(0x43);
      y=spi_read();
      spi_write(0xaa);
      y=spi_read();


   }

}

_________________
Sasidhar
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 1:16 am     Reply with quote

bonjour

try this
y = spi_read(0);

and read the Compiler reference Manual page 162

Bon Courrage Alain
ravellanag



Joined: 20 Sep 2004
Posts: 3

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 1:39 am     Reply with quote

Hi Bon Courrage Alain

I used y=spi_read(0), but same thing is repeating.

same code is used to do loop back without device to test SPI. same error is repeating for the above command also.
_________________
Sasidhar
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 3:36 am     Reply with quote

re bonjour,

which is the version of the compiler
which is the value of Pull-Up resistors for 3.3v to 5V ?
which SPI device ?


ALain
ravellanag



Joined: 20 Sep 2004
Posts: 3

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 4:15 am     Reply with quote

compiler version is 3.028.
i am using only 74HC/HCT244, but not pull up resistor.
At this moment i did not test the program with device, i just doing a self-loopback.
_________________
Sasidhar
drh



Joined: 12 Jul 2004
Posts: 193
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 7:24 am     Reply with quote

The 74HCT244 is not a voltage shifter.
_________________
David
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