|
|
View previous topic :: View next topic |
Author |
Message |
petiot
Joined: 28 Jun 2010 Posts: 5
|
PCD with dspic33: setup_spi function really does not work! |
Posted: Wed Jun 30, 2010 5:58 am |
|
|
dear all,
I am currently writing code for a dsPIC33FJ128MC506. looking at the assembly generated by PCD I have to say that the SPI is not configured properly at all. here is why:
SPI1STAT @ 0x0240
SPI1CON1 @ 0x0242
SPI1CON2 @ 0x0244 control SPI1 operation (pls refer to datasheet)
the function:
setup_spi(SPI_MASTER|SPI_L_TO_H | SPI_CLK_DIV_16); generates:
0024C: BCLR.B 242.7
0024E: BCLR.B 240.6
00250: MOV #3D,W4
00252: MOV W4,242
00254: BSET.B 241.7
The spi clock speed is controlled by primary prescaler and secondary prescaler (SPRE and PRE). PCD leaves SPRE to 111 and only ajusts PRE... Knowing that SPI speed is dependant upon Fcy, that is pretty poor as the SPI speed you will get depends on your oscillator source and settings...
Also, looking at "BCLR.B 240.6", it tries to clear SPIROV bit (again, pls refer to datasheet) which is read only?
And, if that was not enough, there are no SPI_TRANSMIT_L_TO_H defines in the .h file.
IN SHORT, you'll be lucky to get SPI to work on this controller with PCD... The only way to set the registers properly is to use #word Register Address directive and assign the value yourself... Mister CCS, what's the point to provide fonctions which does not work? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Wed Jun 30, 2010 6:27 am |
|
|
Some points:
1. You did not say what VERSION you are using for any of us to test it.
2. This is NOT CCS support. It is a USER forum. If you want to address
your comments to CCS send an email to CCS Support as shown in the
upper right corner of this web page.
3. This topic has already been raised a couple of times before for earlier
versions and workarounds using direct register addressing was suggested. I
do not know if they still apply to the latest software version.
4. The person in this post seems to have SPI working on a dsPIC and his experiences might help.
http://www.ccsinfo.com/forum/viewtopic.php?t=42564 _________________ Google and Forum Search are some of your best tools!!!! |
|
|
petiot
Joined: 28 Jun 2010 Posts: 5
|
thanks |
Posted: Wed Jun 30, 2010 7:38 am |
|
|
dyeatman,
PCD version 4.078 bought a couple of years ago. as you know, you can only update for 30 days... Has this been fixed in newer versions?
I took your remarks onboard, and sorry if this is not the right place to post this as this was my first post.
Thanks for your Help. However, I do know how to get SPI working (exactly the same way as your link, by filling in registers myself). It's just that I would have expected this fonction to work. Otherwise, I might as well stick to a free compiler if I got to write everything myself and not use onboard fonctions because of bugs...
Regards
Serge |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Wed Jun 30, 2010 8:34 am |
|
|
petiot,
Your comment:
Quote: | Mister CCS, what's the point to provide fonctions which does not work? |
was addressed to CCS and I just wanted to be sure you understood they
don't monitor this forum on a regular basis.
Workarounds for some bad functions are common especially in the beta
versions. Since I don't have PCD (yet) I can't speak to whether it has been fixed
as of version 4.109, maybe someone here who has PCD and the dsPIC can?
Some users here, as a matter of course, explicitly do not use the CCS
functions and write their own for portability. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Jun 30, 2010 1:14 pm |
|
|
I have PCD and SPI working -- and I remember having to do the direct register access too...
disable the MSSP, change the clock dividers, enable the MSSP and go.
As for CCS, they are providing functions to ease the pain. In the beginning, they tend to need a little re-adjustment.
Be glad you aren't using C30 where you'd have to do a LOT of things yourself anyway.
That's how I look at it and I seem to be keeping my remaining hair.
-Ben
p.s. if you find a bug in a current version of the compiler, you should email it to support@ccsinfo.com _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|
|
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
|