View previous topic :: View next topic |
Author |
Message |
ravellanag
Joined: 20 Sep 2004 Posts: 3
|
spi question |
Posted: Thu Sep 23, 2004 1:00 am |
|
|
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
|
|
Posted: Thu Sep 23, 2004 1:16 am |
|
|
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
|
|
Posted: Thu Sep 23, 2004 1:39 am |
|
|
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
|
|
Posted: Thu Sep 23, 2004 3:36 am |
|
|
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
|
|
Posted: Thu Sep 23, 2004 4:15 am |
|
|
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: 192 Location: Hemet, California USA
|
|
Posted: Thu Sep 23, 2004 7:24 am |
|
|
The 74HCT244 is not a voltage shifter. _________________ David |
|
|
|