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_read clock

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



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

spi_read clock
PostPosted: Fri Jan 14, 2005 9:46 am     Reply with quote

Hello,

I'm using CCS 3.28 (PCM 3.150). My pic is 16F873A.

I'm using spi_write succesfully with it and I can see the clock. But when I want to read data, I can see any clock : spi_read...

Is it normal ???

Thanks for your reading

Wink
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Jan 14, 2005 10:54 am     Reply with quote

Is your system configured as master or slave? In a slave system you won't see the clock.

For a spi-master, remember SPI is a two-way bus where you are always sending and transmitting simultaneously so spi_read requires a parameter. Depending on whether you want a constant high or low level on the data-output use either spi_read(0x00) or spi_read(0xff).
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Mon Jan 17, 2005 2:12 am     Reply with quote

My PIC is MASTER.

What do you mean by "Depending on whether you want a constant high or low level on the data-output use either spi_read(0x00) or spi_read(0xff)" ?

Thanks for your support Cool
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Mon Jan 17, 2005 3:10 am     Reply with quote

Well I have tested with spi_read(0xFF) and the clock I obtain is only 4 bits long. What shall I do in order to have 8 bits clock ???

Embarassed
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jan 17, 2005 5:30 pm     Reply with quote

Quote:
Well I have tested with spi_read(0xFF) and the clock I obtain is only 4 bits long.
This sounds very strange, I never heard of similar problems before.

Are you using the hardware SPI unit?

Can you post a (small) example program?

Quote:
What do you mean by "Depending on whether you want a constant high or low level on the data-output use either spi_read(0x00) or spi_read(0xff)" ?
I didn't express myself very clear. Using the spi_read() function you will output data as well. Depending on the connected device you have to decide what data you want transmit while reading the bus.
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Tue Jan 18, 2005 2:19 am     Reply with quote

PIC is master, the other component is

Init of the PIC :

setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_CLK_DIV_4);

I send : spi_write(0x7f); and there is no problem

00AE: MOVF 13,W
00AF: MOVLW 7F
00B0: MOVWF 13
00B1: BSF 03.5
00B2: BTFSS 14.0
00B3: GOTO 0B2

spi_read(0) or spi_read(0xFF) have a 4 bits clock :

00D2: MOVF 13,W
00D3: CLRF 13
00D4: BSF 03.5
00D5: BTFSS 14.0
00D6: GOTO 0D5

I have succesfully tested the SPI between 2 PIC with the same function. But it should came from the component.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jan 18, 2005 3:23 am     Reply with quote

It looks like you have a hardware problem, try a 1k Ohm series resistor in the clock line. Also removing the probe might solve the problem.
See this thread http://forum.microchip.com/tm.asp?m=67287
Guest
Guest







PostPosted: Mon Mar 14, 2005 5:39 pm     Reply with quote

ckielstra wrote:
It looks like you have a hardware problem, try a 1k Ohm series resistor in the clock line. Also removing the probe might solve the problem.
See this thread http://forum.microchip.com/tm.asp?m=67287


I just wanted to say thank you for the solution. The problem is the impedance of the probe (or connection to the other device). I found that a 1K-ohm resistor is a little too much, and that 100 ohms is much cleaner of a match (you should see nice square pulses on your probe even using a non-active probe).

Thanks again.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Mar 15, 2005 1:48 am     Reply with quote

Quote:
I just wanted to say thank you for the solution.
You are welcome. Very Happy

Thanks for telling us the problem is solved.
Guest








PostPosted: Sat Nov 05, 2005 10:53 am     Reply with quote

YulL wrote:
PIC is master, the other component is

Init of the PIC :

setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_CLK_DIV_4);

I send : spi_write(0x7f); and there is no problem

00AE: MOVF 13,W
00AF: MOVLW 7F
00B0: MOVWF 13
00B1: BSF 03.5
00B2: BTFSS 14.0
00B3: GOTO 0B2

spi_read(0) or spi_read(0xFF) have a 4 bits clock :

00D2: MOVF 13,W
00D3: CLRF 13
00D4: BSF 03.5
00D5: BTFSS 14.0
00D6: GOTO 0D5

I have succesfully tested the SPI between 2 PIC with the same function. But it should came from the component.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 06, 2005 5:45 pm     Reply with quote

Dear Guest,

First some general remarks
1) The formatting of your question is very difficult to read.
2) Please register yourself to this forum. Besides being polite this gives you the option to edit your messages and fix possible errors in your post.....
3) When posting a question alway mention:
- The processor you are using.
- Your compiler version.

For your problem:
- Have you tried to insert a 100 Ohm resistor in the clock line as suggested?
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