You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Roberto Bucher <ro...@supsi.ch> on 2022/03/04 07:34:24 UTC

SPI Example

Hi

where can I found a simple example that send n bytes to the SPI and 
receive m bytes?

I can now see the /dev/spi but using simple methods like open and write 
doesn't give me any signal on the bus...

Thanks in advance

Roberto


Re: SPI Example

Posted by Simon Filgis <si...@ingenieurbuero-filgis.de>.
Hi Roberto,

maybe Lup's article can help:

https://lupyuen.github.io/articles/spi2

Which platform do you use?

Simon

--
Hard- and Softwaredevelopment Consultant
Ingenieurbüro-Filgis
USt-IdNr.: DE305343278


On Fri, Mar 4, 2022 at 8:41 AM Roberto Bucher <ro...@supsi.ch>
wrote:

> Hi
>
> where can I found a simple example that send n bytes to the SPI and
> receive m bytes?
>
> I can now see the /dev/spi but using simple methods like open and write
> doesn't give me any signal on the bus...
>
> Thanks in advance
>
> Roberto
>
>

Re: SPI Example

Posted by Roberto Bucher <ro...@supsi.ch>.
I followed a bit the problem with the SPI bus and I reached to find 
where I have the first problem:

1) In the shell: spi bus gives me that the BUS 2 is available
2) I launch "spi -b2 -x4 aabbccdd" and I pass through the following files:
     apps/system/spi/spi_exch.c -> apps/system/spi/spi_devif.c -> 
nuttx/drivers/spi/spi_driver.c -> /nuttx/drivers/spi/spi_transfer.c

     which sould be ok.

3) In spi_transfer.c , the line "SPI_LOCK(spi, true)" causes the dump!

When I try to set the DEBUG ASSERTION in "make menuconfig", this causes 
a dump directly when I enter the nuttx shell in my nucleo-144 board...

It is quite difficult to find out an idea to follow the problem yet...

Best regards

Roberto

On 3/4/22 13:34, Alan Carvalho de Assis wrote:
> Hi Roberto,
>
> Enable the DEBUG ASSERTION to see where the crash is happening?
>
> What you get when you run:
>
> nsh> spi bus
>
> Maybe you passing an invalid bus number.
>
> BR,
>
> Alan
>
> On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
>> Thanks Alan, but the main problem is that this test gives me an error by
>> the execution on my STM32F7 nucleo-144 board...
>>
>> nsh> spi exch -b 2 -x 4 aabbccdd
>> Seup_assert: Assertion failed at file:armv7-m/arm_hardfault.c line: 174
>> arm_registerdump: R0: 00000000 R1: 2001a334 R2: 00000001  R3: 00002201
>> arm_registerdump: R4: 00000000 R5: 00002201 R6: 2004f774  FP: 2004f770
>> arm_registerdump: R8: 2001a380 SB: 00000005 SL: 2001a358 R11: 2001a35c
>> arm_registerdump: IP: 00000018 SP: 2001a2b0 LR: 08016f63  PC: 0801700c
>> arm_registerdump: xPSR: 61000000 PRIMASK: 00000000 CONTROL: 00000000
>> arm_registerdump: EXC_RETURN: ffffffe9
>> arm_dump_stack: User Stack:
>> arm_dump_stack: sp:     2001a170
>> arm_dump_stack:   base: 20019c70
>> arm_dump_stack:   size: 000007c8
>> arm_stackdump: 2001a160: 20019c70 2001a170 20011d50 0801b447 00000000
>> 00000000 0801700c 00000000
>> arm_stackdump: 2001a180: 00000000 08021224 0801700a 080236b8 2004f774
>> 2004f770 2
>> ....
>>
>> BR
>>
>> Roberto
>>
>> On 3/4/22 12:29, Alan Carvalho de Assis wrote:
>>> Hi Roberto,
>>>
>>> We have the SPI Tool that does exactly what you want:
>>>
>>> Application Configuration  --->
>>>       System Libraries and NSH Add-Ons  --->
>>>           [*] SPI tool  --->
>>>
>>> BR,
>>>
>>> Alan
>>>
>>> On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
>>>> Hi
>>>>
>>>> where can I found a simple example that send n bytes to the SPI and
>>>> receive m bytes?
>>>>
>>>> I can now see the /dev/spi but using simple methods like open and write
>>>> doesn't give me any signal on the bus...
>>>>
>>>> Thanks in advance
>>>>
>>>> Roberto
>>>>
>>>>
>>


Re: SPI Example

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Roberto,

Enable the DEBUG ASSERTION to see where the crash is happening?

What you get when you run:

nsh> spi bus

Maybe you passing an invalid bus number.

BR,

Alan

On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
> Thanks Alan, but the main problem is that this test gives me an error by
> the execution on my STM32F7 nucleo-144 board...
>
> nsh> spi exch -b 2 -x 4 aabbccdd
> Seup_assert: Assertion failed at file:armv7-m/arm_hardfault.c line: 174
> arm_registerdump: R0: 00000000 R1: 2001a334 R2: 00000001  R3: 00002201
> arm_registerdump: R4: 00000000 R5: 00002201 R6: 2004f774  FP: 2004f770
> arm_registerdump: R8: 2001a380 SB: 00000005 SL: 2001a358 R11: 2001a35c
> arm_registerdump: IP: 00000018 SP: 2001a2b0 LR: 08016f63  PC: 0801700c
> arm_registerdump: xPSR: 61000000 PRIMASK: 00000000 CONTROL: 00000000
> arm_registerdump: EXC_RETURN: ffffffe9
> arm_dump_stack: User Stack:
> arm_dump_stack: sp:     2001a170
> arm_dump_stack:   base: 20019c70
> arm_dump_stack:   size: 000007c8
> arm_stackdump: 2001a160: 20019c70 2001a170 20011d50 0801b447 00000000
> 00000000 0801700c 00000000
> arm_stackdump: 2001a180: 00000000 08021224 0801700a 080236b8 2004f774
> 2004f770 2
> ....
>
> BR
>
> Roberto
>
> On 3/4/22 12:29, Alan Carvalho de Assis wrote:
>> Hi Roberto,
>>
>> We have the SPI Tool that does exactly what you want:
>>
>> Application Configuration  --->
>>      System Libraries and NSH Add-Ons  --->
>>          [*] SPI tool  --->
>>
>> BR,
>>
>> Alan
>>
>> On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
>>> Hi
>>>
>>> where can I found a simple example that send n bytes to the SPI and
>>> receive m bytes?
>>>
>>> I can now see the /dev/spi but using simple methods like open and write
>>> doesn't give me any signal on the bus...
>>>
>>> Thanks in advance
>>>
>>> Roberto
>>>
>>>
>
>

Re: SPI Example

Posted by Roberto Bucher <ro...@supsi.ch>.
Thanks Alan, but the main problem is that this test gives me an error by 
the execution on my STM32F7 nucleo-144 board...

nsh> spi exch -b 2 -x 4 aabbccdd
Seup_assert: Assertion failed at file:armv7-m/arm_hardfault.c line: 174
arm_registerdump: R0: 00000000 R1: 2001a334 R2: 00000001  R3: 00002201
arm_registerdump: R4: 00000000 R5: 00002201 R6: 2004f774  FP: 2004f770
arm_registerdump: R8: 2001a380 SB: 00000005 SL: 2001a358 R11: 2001a35c
arm_registerdump: IP: 00000018 SP: 2001a2b0 LR: 08016f63  PC: 0801700c
arm_registerdump: xPSR: 61000000 PRIMASK: 00000000 CONTROL: 00000000
arm_registerdump: EXC_RETURN: ffffffe9
arm_dump_stack: User Stack:
arm_dump_stack: sp:     2001a170
arm_dump_stack:   base: 20019c70
arm_dump_stack:   size: 000007c8
arm_stackdump: 2001a160: 20019c70 2001a170 20011d50 0801b447 00000000 
00000000 0801700c 00000000
arm_stackdump: 2001a180: 00000000 08021224 0801700a 080236b8 2004f774 
2004f770 2
....

BR

Roberto

On 3/4/22 12:29, Alan Carvalho de Assis wrote:
> Hi Roberto,
>
> We have the SPI Tool that does exactly what you want:
>
> Application Configuration  --->
>      System Libraries and NSH Add-Ons  --->
>          [*] SPI tool  --->
>
> BR,
>
> Alan
>
> On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
>> Hi
>>
>> where can I found a simple example that send n bytes to the SPI and
>> receive m bytes?
>>
>> I can now see the /dev/spi but using simple methods like open and write
>> doesn't give me any signal on the bus...
>>
>> Thanks in advance
>>
>> Roberto
>>
>>


Re: SPI Example

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Roberto,

We have the SPI Tool that does exactly what you want:

Application Configuration  --->
    System Libraries and NSH Add-Ons  --->
        [*] SPI tool  --->

BR,

Alan

On 3/4/22, Roberto Bucher <ro...@supsi.ch> wrote:
> Hi
>
> where can I found a simple example that send n bytes to the SPI and
> receive m bytes?
>
> I can now see the /dev/spi but using simple methods like open and write
> doesn't give me any signal on the bus...
>
> Thanks in advance
>
> Roberto
>
>