Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:30 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SPI SETPIN Error

Author Message
wolfme
Newbie

Joined: 26/10/2021
Location: Germany
Posts: 29
Posted: 10:47pm 09 Mar 2024
Copy link to clipboard 
Print this post

Hi,

if i run the SPI commands

SETPIN GP4, GP3, GP2, SPI

as in the example on page 133 of the manual on a picomite vga, i get error: SPI in use for SYSTEM SPI

This happens for all other SPI or SPI2 pins, too.

What do i wrong?
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 11:57pm 09 Mar 2024
Copy link to clipboard 
Print this post

Hi wolfme,

You probably have an option set for system SPI (maybe for a TFT screen)

In that case you can still use the SPI but no need to do the SETPIN again.  

I know this is the case for I2C so I would assume it’s the same for SPI.

Kind Regards,

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 02:43am 10 Mar 2024
Copy link to clipboard 
Print this post

As Mick wrote, check if System SPI is on SPI1 or SPI2 then you can separately set the other one without error. SPI1 is just called SPI for consistency with other systems.

System SPI is called System SPI regardless of whether it uses SPI1 or SPI2 pins, so you need to check the pin allocation diagram in the PicoMite Hardware chapter.
> option list
PicoMite MMBasic Version 5.09.00b6
OPTION SYSTEM SPI GP18,GP19,GP16 '<--System SPI is on SPI1
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION CPUSPEED  378000 'KHz
OPTION DISPLAY 55, 128
OPTION LCDPANEL ILI9341, LANDSCAPE,GP15,GP14,GP13
OPTION TOUCH GP12,GP11
GUI CALIBRATE 0, 3923, 3867, -881, -649
OPTION SDCARD GP17
>
> SETPIN GP26, GP27, GP28, SPI2 '<--Clk, Tx, Rx - Can be set without error.
>

Search the manual for System SPI for more info.
Edited 2024-03-10 13:23 by phil99
 
wolfme
Newbie

Joined: 26/10/2021
Location: Germany
Posts: 29
Posted: 07:52am 10 Mar 2024
Copy link to clipboard 
Print this post

Thanks for the answers.

Here ist my option list:

> option list
PicoMiteVGA MMBasic Version 5.08.00
OPTION SYSTEM I2C GP14,GP15
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION KEYBOARD GR
OPTION PICO OFF
OPTION CPUSPEED (KHz) 252000
OPTION SDCARD GP13, GP10, GP11, GP12
OPTION AUDIO SPI GP24,GP22,GP23', ON PWM CHANNEL 3
OPTION RTC AUTO ENABLE
>

There's no SYSTEM SPI Set.
I'm using a VGA version on Peter's PCB V1.1a design.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 08:04am 10 Mar 2024
Copy link to clipboard 
Print this post

One spi channel is used by the audio the other by the sdcard - nothing left
 
wolfme
Newbie

Joined: 26/10/2021
Location: Germany
Posts: 29
Posted: 08:41am 10 Mar 2024
Copy link to clipboard 
Print this post

  matherp said  One spi channel is used by the audio the other by the sdcard - nothing left


Oh, ok, Thanks.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4232
Posted: 11:24am 10 Mar 2024
Copy link to clipboard 
Print this post

Sd card uses SPI hardware? I was under the impression that SD card was bit-banged. Maybe it was in the past.
Volhout.
PicomiteVGA PETSCII ROBOTS
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 01:05pm 10 Mar 2024
Copy link to clipboard 
Print this post

So (if I understand correctly), to use SPI2 for other SPI devices, first:


OPTION SYSTEM SPI GP10, GP11, GP12
OPTION SDCARD GP13


Then you can use SPI2 READ and SPI2 WRITE (SPI2 because GP10/11/12 are SPI1, not SPI0).
You must handle chip select in code.

~
Edited 2024-03-10 23:07 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 02:31pm 10 Mar 2024
Copy link to clipboard 
Print this post

If you specify spi pins for the SDcard then the firmware will assume it can use SPI and lock that spi channel. Option System SPI is only relevant to non-VGA versions and in that case the SPI channel can also be used for touch and LCD panel but nothing else.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 03:27pm 10 Mar 2024
Copy link to clipboard 
Print this post

  matherp said  If you specify spi pins for the SDcard then the firmware will assume it can use SPI and lock that spi channel.


Does this imply that if you specify non-spi pins, the SD card will be bit-banged, and then SPI will be available for other uses? E.g., GP20, 21, and 22?

Maybe the broader question is: Is there a way to use audio and LCD with touch and SD card and another SPI device? Or must another SPI device be bit-banged on another set of pins?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 03:48pm 10 Mar 2024
Copy link to clipboard 
Print this post

  Quote  Does this imply that if you specify non-spi pins, the SD card will be bit-banged, and then SPI will be available for other uses? E.g., GP20, 21, and 22?

Yes
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 06:19pm 10 Mar 2024
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Does this imply that if you specify non-spi pins, the SD card will be bit-banged, and then SPI will be available for other uses? E.g., GP20, 21, and 22?

Yes


which is only half the answer.

  Quote  OPTION SYSTEM SPI CLKpin, MOSIpin, MISOpin
Specify or disable the SPI port and pins for use by system devices (SD Card, LCD panel, etc).
The PicoMite uses a specific hardware SPI port for system devices, leaving the other for the user. This command specifies which pins are to be used, and hence which of the SPI ports is to be used. The pins allocated to the SYSTEM SPI will not be available to other MMBasic commands.

OPTION SDCARD CSpin [,CLKpin, MOSIpin, MISOpin]
Specify or disable the I/O pins to use for the SD Card interface. If the optional pins are not specified the SD Card will use the pins specified by OPTION SYSTEM SPI.
Note: The pins specified by OPTION SYSTEM SPI must be a valid set of hardware SPI pins (SPI or SPI2), however, the pins specified by OPTION SDCARD can be any pins. The pins specified by OPTION SYSTEM SPI and OPTION SDCARD cannot be the same.


as i recall, Peter attempted to use hardware SPI to access the SD card, but was unable to get it working reliably. so he implemented access in software (bitbanged) instead. i believe this is still the case - Peter will need to confirm - and so if OPTION SYSTEM SPI CLKpin, MOSIpin, MISOpin and OPTION SDCARD CSpin are set, then hardware SPI on the selected pins is disabled during SD card access (access bitbanged instead), but enabled during LCD, touch panel, etc access to maximize graphic speed.

Peter - can you please confirm this, preferably with more than a one word sentence?


cheers,
rob   :-)
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024