Hello!
I am using Arduino circuit Mega2560 SPI data transfer.
I experienced the following problems:
If you set the SPI hardware does not work the other ports.
RB4 will set SPI chip enable pint set(not work) after initialization.
I watched the communication, there is CLK output SDO data output, only the chip enable output value does not change.
If the SPI software I use the Flowcode not saved bits set the output port.
DAC En $ PORTA.3
En NVM $ PORTA.4
En MOSI (SDO) $ PORTA.5
MISO En (SDI) $ PORTC.4
CLK $ PORTC.3
This configuration is always loaded.
Examples are:http://www.matrixmultimedia.com/mmforum ... 330#p56894
Arduino Mega2560 SPI bug
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Arduino Mega2560 SPI bug
Hello,
Sorry this one must have slipped through my net.
The program you link to is set to software mode, I guess this is working as it should to provide the functionality shown in the video. So the problem is hardware SPI only.
Let me know if I've got anything wrong.
Sorry this one must have slipped through my net.
So your saying if you enable SPI hardware you cannot use any other I/O pins? Have you a program that replicates this bug?If you set the SPI hardware does not work the other ports.
I assume this means that RB4 is an I/O pin connected to the SPI CS pin but cannot be used because of the issue mentioned above.RB4 will set SPI chip enable pint set(not work) after initialization.
So the SPI bus is working but nothing else?I watched the communication, there is CLK output SDO data output, only the chip enable output value does not change.
The program you link to is set to software mode, I guess this is working as it should to provide the functionality shown in the video. So the problem is hardware SPI only.
Let me know if I've got anything wrong.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Arduino Mega2560 SPI bug
Hello,
I've done some investigation and the problem isn't anything to do with Flowcode, it's a feature of AVR! If you setup hardware SPI on an AVR device then it will automatically allow the Slave Select functionality even in Master mode?!
This means if the SS pin (RB0 on the Mega 2560) floats high then the SPI hardware will lock up every time. Outputting a 1 or 0 to the SS pin should force the pin into output mode and the issue should then go away. Testing on hardware then seems to work fine.
I could override this in the CAL code but this may break the functionality of anything you have on the SS pin which might not be ideal.
I've done some investigation and the problem isn't anything to do with Flowcode, it's a feature of AVR! If you setup hardware SPI on an AVR device then it will automatically allow the Slave Select functionality even in Master mode?!
This means if the SS pin (RB0 on the Mega 2560) floats high then the SPI hardware will lock up every time. Outputting a 1 or 0 to the SS pin should force the pin into output mode and the issue should then go away. Testing on hardware then seems to work fine.
I could override this in the CAL code but this may break the functionality of anything you have on the SS pin which might not be ideal.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- STibor
- Posts: 263
- Joined: Fri Dec 16, 2011 3:20 pm
- Has thanked: 116 times
- Been thanked: 113 times
- Contact:
Re: Arduino Mega2560 SPI bug
Hi!
My English is bad for me, it was not possible to understand description of the problem.
The SPI master mode, use it.
Software SPI works, but does not save the port settings.
Hardware SPI with the clock and the data goes and blocks the ports so that the CS is always high.
See the hardware and SS output that works with any communication.
This means that if you run the SPI communication, ports are blocked?
Edit: PB0 it works with hardware SPI Chip Enable port.
My English is bad for me, it was not possible to understand description of the problem.
The SPI master mode, use it.
Software SPI works, but does not save the port settings.
Hardware SPI with the clock and the data goes and blocks the ports so that the CS is always high.
See the hardware and SS output that works with any communication.
This means that if you run the SPI communication, ports are blocked?
Edit: PB0 it works with hardware SPI Chip Enable port.
Re: Arduino Mega2560 SPI bug
Hello, I am using ARDUINO MEGA 2560 R3 and I am connecting it to AD7606 (ADC analog to digital converter). I am using SPI and set initialization by Hardware: freq. clk=fosc/2 but it does not run as expected in 8Mhz, instead it runs at 510Khz (too slow for my application). I do not have any other problem, except that my SPI clock is too slow because I want to receive serial comm bit by bit. Can you tell me what to do? Thank you!!!
Re: Arduino Mega2560 SPI bug
Hello, I am using ARDUINO MEGA 2560 R3 and I am connecting it to AD7606 (ADC analog to digital converter). I am using SPI and set initialization by Hardware: freq. clk=fosc/2 but it does not run as expected in 8Mhz, instead it runs at 510Khz (too slow for my application). I do not have any other problem, except that my SPI clock is too slow because I want to receive serial comm bit by bit. Can you tell me what to do? Thank you!!!