|
|
View previous topic :: View next topic |
Author |
Message |
Rob Guest
|
Writing customized drivers |
Posted: Mon Mar 10, 2003 1:59 pm |
|
|
Hello;
I am interested in bastardizing the functions: spi_read, spi_write, spi_data_is_in. Why?, I have a chip that needs me to toggle a different line before (and after) sending it SPI data. I have not looked at the assembler that it generates yet.....Do any of you have any experience writing driver(s) for the compiler and linking them? Or am I stuck writing assembly macros?
What exactly are the ccs spi_ routines doing? Do they check the SPI flags? Can I interupt out of them safely and return? Do they use any variable space? Do they clean up when finished....or are they really simple?
Thx...Rob
___________________________
This message was ported from CCS's old forum
Original Post ID: 12504 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: Writing customized drivers |
Posted: Mon Mar 10, 2003 2:03 pm |
|
|
:=Hello;
:=
:= I am interested in bastardizing the functions: spi_read, spi_write, spi_data_is_in. Why?, I have a chip that needs me to toggle a different line before (and after) sending it SPI data. I have not looked at the assembler that it generates yet.....Do any of you have any experience writing driver(s) for the compiler and linking them? Or am I stuck writing assembly macros?
:=
:= What exactly are the ccs spi_ routines doing? Do they check the SPI flags? Can I interupt out of them safely and return? Do they use any variable space? Do they clean up when finished....or are they really simple?
:=
:=Thx...Rob
You can interupt while using the CCS SPI functions.
<a href="http://www.pic-c.com/forum/general/posts/12505.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/12505.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12506 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Writing customized drivers |
Posted: Mon Mar 10, 2003 2:23 pm |
|
|
:=Hello;
:=
:= I am interested in bastardizing the functions: spi_read, spi_write, spi_data_is_in. Why?, I have a chip that needs me to toggle a different line before (and after) sending it SPI data. I have not looked at the assembler that it generates yet.....Do any of you have any experience writing driver(s) for the compiler and linking them? Or am I stuck writing assembly macros?
:=
:= What exactly are the ccs spi_ routines doing? Do they check the SPI flags? Can I interupt out of them safely and return? Do they use any variable space? Do they clean up when finished....or are they really simple?
--------------------------------------------------------------
To see the ASM code created by the compiler, make a small
test program and look at the .LST file. Here is what the
spi_write() function does:
<PRE>
0000 00287 .................... spi_write(0x55); <BR>
0014 0813 00288 MOVF 13,W // Read SSPBUF
0015 3055 00289 MOVLW 55
0016 0093 00290 MOVWF 13 // Put 0x55 in SSPBUF
0017 1683 00291 BSF 03.5 // Bank 1
0018 1814 00292 BTFSC 14.0 // Test BF bit of SSPSTAT
0019 281C 00293 GOTO 01C // Jump if BF bit = 1
001A 1283 00294 BCF 03.5 // Bank 0
001B 2817 00295 GOTO 017 // Wait in loop until BF = 1
001C 1283 00296 BCF 03.5
</PRE>
This was compiled with PCM vs. 3.148, for a 16F877.
-----------
For bit-banged SPI code, see Peter Anderson's page.
<a href="http://www.phanderson.com/PIC/PICC/index.html" TARGET="_blank">http://www.phanderson.com/PIC/PICC/index.html</a>
See his code for the LTC1298 and others.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12507 |
|
|
Rob Guest
|
Re: Writing customized drivers |
Posted: Mon Mar 10, 2003 2:28 pm |
|
|
:=:=Hello;
:=:=
:=:= I am interested in bastardizing the functions: spi_read, spi_write, spi_data_is_in. Why?, I have a chip that needs me to toggle a different line before (and after) sending it SPI data. I have not looked at the assembler that it generates yet.....Do any of you have any experience writing driver(s) for the compiler and linking them? Or am I stuck writing assembly macros?
:=:=
:=:= What exactly are the ccs spi_ routines doing? Do they check the SPI flags? Can I interupt out of them safely and return? Do they use any variable space? Do they clean up when finished....or are they really simple?
:=:=
:=:=Thx...Rob
:=
:=You can interupt while using the CCS SPI functions.
:=
:= <a href="http://www.pic-c.com/forum/general/posts/12505.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/12505.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/12505.html</a></a>
At first look, I disagree with you on your point. If I look at the assembly that the compiler produced, it looks like I could have a problem interupting out if I came back in at the wrong place. Here is a clip of the assembler:
003E 30FE movlw 0xFE
003F 1683 bsf 0x3,0x5
0040 0088 movwf 0x8
0041 1283 bcf 0x3,0x5 PAGESEL
0042 1008 bcf 0x8,0x0
0043 0813 movf 0x13,W
0044 3001 movlw 0x1 DATA OUT
0045 0093 movwf 0x13 SSPBUFF
0046 1683 bsf 0x3,0x5
0047 1814 btfsc 0x14,0x0 SSPSTAT:0
0048 284B goto 0x4B
0049 1283 bcf 0x3,0x5
004A 2846 goto 0x46
004B 1283 bcf 0x3,0x5
004C 00A2 movwf 0x22
If you look, you will see that the spi write or read here is just a simple loop, testing SSPSTAT:0 for completion. This is exactly why I want to bastardize the routines I mentioned.
Do any of you have experience compiling and linking new routines into the compiler?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12508 |
|
|
Steve H Guest
|
Drivers are just code..... |
Posted: Mon Mar 10, 2003 2:55 pm |
|
|
There is no linking of code in this compiler - you don't have an object code layer to play with. You just write your own code include it or have it in the main body and compile away.
I for one always use my own SPI routines because the parts I use nearly always don't use exactly 8 bits of data, so I bit bang the routines myself.
PCM gave you an excelent link or you can view the code on my site for some more examples,
Regards,
Steve H.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12509 |
|
|
|
|
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
|