Can Orangutan X2 interface with SPI mode 3 device?


I understand that the Orangutan X2 operates on SPI mode 0:

•clock polarity 0 (clock line low when idle)
•clock phase 0 (sample on leading ege)

I am trying to interface it with a SPI mode 3 device (NXP SC18IS600601 SPI to I2C bus interface). Is it possible to do so at all, and if so, would it disrupt the SPI communication between the 1284P and 328P?



I moved your thread from the Motor Controller forum to the Orangutan forum.

I’m not sure how feasible it is to communicate with SPI slaves using two different modes on the same bus, but I think it could work. The ATmega328P’s slave select line is accessible via a through hole in the middle of the PCB; you should be able to connect an I/O line to this pin and use it to keep the auxiliary MCU from responding to the communications you send to your external device. Note that you will also have to reconfigure the clock polarity and phase of the SPI module every time you want to communicate with a different SPI slave.

However, it might be easier if you use software I2C to talk to your external device (master I2C is pretty easy to implement in software, and there are probably a number of master I2C AVR libraries out there if you google around), or you could also consider using one of the USARTs in synchronous (SPI) mode.

- Ben

Hi Ben,

Thanks for your reply. I’d probably take up the alternative I2C methods you mentioned, but right now I am trying to delve a little deeper into the Orangutan X2’s SPI functionality. Specifically, I am trying to readback the ATmega328P’s firmware version using Command 253: Get Firmware version.

I am using AVR Studio 4 and am having some problems integrating SPI.[ch] into the project. I started a Orangutan X2 project from scratch. Then I added SPI.h into the project’s Header Files and SPI.c into the project’s Source Files.

When I just have SPIInit() in the main() function, the compiler will give the warning “…/Test.c:10: warning: implicit declaration of function ‘SPIInit’”. But since it compiles, I just let it go.

However, when I start adding other “standard” Orangutan functions (such as serial_set_baud_rate(USB_COMM,115200)) to main(), the compiler will start to come back with errors, such as:

"c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib\libpololu_atmega1284p_x2.a(OrangutanTime.o): In function `time_reset':
/home/david/lib-orangutan/devices/atmega1284p_x2/../../src/OrangutanTime/../../src/OrangutanTime/OrangutanTime.cpp:109: multiple definition of `delay_ms'"

Is this a linker issue, or do I need to recompile libpololu_atmega1284p_x2.a (with SPI.[ch] to solve this? Or maybe I have overlooked something simple?

Would appreciate your advice on this. Thanks!


The code in the SPI files you’re trying to use has already been integrated into the Pololu AVR library, so you are getting conflicts between the duplicated functions. The SPI functions are now in OrangutanSPIMaster.

All of the Orangutan X2 SPI commands are implemented in libpololu-avr/src/OrangutanX2/OrangutanX2.cpp. If you have any questions about those, please don’t hesitate to ask.

- Ben

Hi Ben,

Just a quick check on the Orangutan X2 version: I used the following function to get the firmware version:

void x2_get_firmware_version(unsigned char *vmajor, unsigned char *vminor);

I got vmajor = 1 and vminor = 3. So does that translate to firmware version 1.3 or 1.03? Is this the latest X2 firmware version?



You have the latest version.

- Ben