18F26K20 SD Testing

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

18F26K20 SD Testing

Post by ohararp » Fri Jan 09, 2009 6:55 pm

Steven,

I was wondering if you have tried using the SD Library with the 18F26K20. I tried doing so a little while back and didn't have much luck. Maverick pinged me the other day and I would like to revisit this, but before I did I wanted to touch base with you on this.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Fri Jan 09, 2009 7:46 pm

Hi Ryan,

No, I haven't used a 18F26K20 yet. Are the SPI registers standard or are they named differntly maybe?

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Fri Jan 09, 2009 9:11 pm

Steven, it looks like they are the same

18F2620 - http://ww1.microchip.com/downloads/en/D ... 39626e.pdf
17.3.1 REGISTERS
The MSSP module has four registers for SPI mode
operation. These are:
• MSSP Control Register 1 (SSPCON1)
• MSSP Status Register (SSPSTAT)
• Serial Receive/Transmit Buffer Register
(SSPBUF)
• MSSP Shift Register (SSPSR) – Not directly
accessible
SSPCON1 and SSPSTAT are the control and status
registers in SPI mode operation. The SSPCON1 register
is readable and writable. The lower 6 bits of the
SSPSTAT are read-only. The upper two bits of the
SSPSTAT are read/write.
SSPSR is the shift register used for shifting data in or
out. SSPBUF is the buffer register to which data bytes
are written to or read from.
In receive operations, SSPSR and SSPBUF together
create a double-buffered receiver. When SSPSR
receives a complete byte, it is transferred to SSPBUF
and the SSPIF interrupt is set.
During transmission, the SSPBUF is not doublebuffered.
A write to SSPBUF will write to both SSPBUF
and SSPSR.
18F26K20 - http://ww1.microchip.com/downloads/en/D ... 80404A.pdf
17.3.1 REGISTERS
The MSSP module has four registers for SPI mode
operation. These are:
• SSPCON1 – Control Register
• SSPSTAT – STATUS register
• SSPBUF – Serial Receive/Transmit Buffer
• SSPSR – Shift Register (Not directly accessible)
SSPCON1 and SSPSTAT are the control and STATUS
registers in SPI mode operation. The SSPCON1 register
is readable and writable. The lower 6 bits of the
SSPSTAT are read-only. The upper two bits of the
SSPSTAT are read/write.
SSPSR is the shift register used for shifting data in and
out. SSPBUF provides indirect access to the SSPSR
register. SSPBUF is the buffer register to which data
bytes are written, and from which data bytes are read.
In receive operations, SSPSR and SSPBUF together
create a double-buffered receiver. When SSPSR
receives a complete byte, it is transferred to SSPBUF
and the SSPIF interrupt is set.
During transmission, the SSPBUF is not
double-buffered. A write to SSPBUF will write to both
SSPBUF and SSPSR.
ERRATA Check - Steven I purchased these units in July and it looks like there might some issues with the MSSP module on these. - http://ww1.microchip.com/downloads/en/D ... 80379A.pdf
8. Module: MSSP SPI
When the SPI clock is configured for Timer2 output/2
(SSPCON1<3:0> = 0011), the first SPI high time
may be short.
Work around
Option 1: Ensure TMR2 value rolls over to zero
immediately before writing to SSPBUF.
Option 2: Turn Timer2 off and clear TMR2 before
writing SSPBUF. Enable TMR2 after SSPBUF is
written.

9. Module: MSSP SPI
In SPI Master mode, when the CKE bit is cleared
and the SMP bit is set, the last bit of the incoming
data stream (bit 0) at the SDI pin will not be
sampled properly.
Work around
None.

10. Module: MSSP SPI
In SPI Master mode, when CKE bit is set, the
SSPBUF will reload the SSPSR output shift register
on every high-to-low transition of the SS pin.
Work around
Avoid using the SS pin when the CKE bit is set and
the MSSP is configured for SPI Master mode.

11. Module: MSSP SPI
When SPI is enabled in Master mode with
CKE = 1 and CKP = 0, a 1/FOSC wide pulse will
occur on the SCK pin.
Work around
Configure the SCK pin as an input until after the
MSSP is setup.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Sun Jan 11, 2009 10:31 am

Ryan I sent you an email about this as I can not post in for some reason!

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sun Jan 11, 2009 11:42 am

Dear Ryan, Doj and Steven,
Well Ryan, glad to hear that you are one step ahead of me in getting the 18F26K20. I have just ordered it one month ago and still waiting for the chip. Surprisingly the lead time is almost 3 months; to get the chip delivered.

I intend to use the chip for my project as well. And I am running SDFilesystem module in my current PIC 18F2525. It seems handy if I can port the code to the new chip without modifications / minor changes.

So I will be more than glad to hear from any of you who have head start of me to meet any luck in making it run on SF.

I am hoping the K series will run faster than my old 2525. Hope to hear more from you. And Doj, do you mind to post your reply again.

Thanks.
Regards,
Liak.

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Sun Jan 11, 2009 2:31 pm

Hello Liak,
I have been working with K20 pics since the first engineering samples last year and they have now only one real issue that I had a problem with.
It is an issue with the SPI module that stops the receive working if the module is not disabled between every single byte received.

Three month on from trying to find out why, I solved the issue a few days ago.

I tried to post the code and the forum tells me it is forbidden and will not allow me to post the code so I am unable to do that just now.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Mon Jan 12, 2009 5:38 am

Dear Doj,
Very glad to hear that you managed to solve the problem. So as for the solution for the faulty SPI module, how to overcome it? Can you somehow send me a copy of what you intended to post on the forum earlier? Can you PM me a copy? I have yet still to receive the chip to try it.

Help will be greatly appreciated.

Regards,
Liak

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Mon Jan 12, 2009 11:54 pm

I tried to send you the code via PM but it too will not let me post it, for some reason the forum will not allow the text in my post to be submited.
I have no idea why, if you post an email address I can send it that way.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Tue Jan 13, 2009 2:34 pm

Dear Doj,
Thanks for the help. I have pm you my email address.

Regards,
Liak

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Wed Jan 14, 2009 6:38 am

Dear Mark and Ryan,
Since I am still waiting to get the K series on my hand, I would like to ask some advise from you guys. BTW thanks again Mark for the reply. I have received the email.
Have you people run into any problem programming the K series using SF? Just an advanced notice of any problem that I may encounter using it.

Thanks.

Regards,
Liak

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Wed Jan 14, 2009 2:19 pm

Liak, the only K series that I have used extensively is the 44K20. It is programmed with a PICKit2 and I have not had any issues. It uses a 16MHz resonator with PLL giving a 64Mhz clock. For this application, entirely coded in Swordfish (my favorite compiler and the ONLY reason why I still use some 8-bit PICs - just wishing for PIC24/dsPIC33 support), the 44K20 controls a 128x64 GLCD, 24 capacitive touch keys/buttons, 6 LEDs and piezo buzzer. All 4 timers are used and mostly interrupt driven (using both HIGH and LOW priority).
Image

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Thu Jan 15, 2009 1:29 am

Dear rmteo,

Thanks for sharing. Nice to hear some K series brother running well outside on SF.
Yeah one point I definite agree with you! I am so deeply in love with SF! Definitely efficient and exact compiler.

After reading through some features of PIC24, the desire to move over the platform is swelling! 16bits bus and ALU, and single execution in 2 clock cycles... The desire to use it is akin to owning a sport car! If only SF runs on it. :P


Is David working on anything in this direction? :?:
I will definitely be joining rmteo in his rush to own it.

Regards,
Liak

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Thu Jan 15, 2009 1:57 am

The only official statement is here:
http://www.sfcompiler.co.uk/wiki/pmwiki ... evelopment
Will Swordfish Support the dsPIC or PIC24 Microcontroller?

We are actively looking at this, but no timescales at the moment I'm afraid. The architecture is very different from the 18 series, so it's a big piece of work - but it is work in progress.
Right now I use a competitor's compiler for the PIC24H/J and dsPIC33s. They are really nice (much easier to use compared to the PIC18s) and they are my first choice when selecting a microCHIP MCU.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Jan 15, 2009 3:06 pm

Something is in development, but at the moment I cannot say much more.

rubenpena
Registered User
Registered User
Posts: 32
Joined: Sun Mar 25, 2007 2:07 am
Location: Monterrey,Mexico

18f25k20 and 18f45k20

Post by rubenpena » Tue Jan 20, 2009 5:55 am

Ohararp:
I have used the 25k20 and the 45k20 with the SD library (thanks to Steven).Both worked very well for playing Wav Files.
If you still have problems, I can send to you the configuration I did use.
Greetings...
Ruben de la Pena V.

Post Reply