paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Paparazzi-devel] Trouble with TWOG as SPI-master


From: Sven Lorenz
Subject: [Paparazzi-devel] Trouble with TWOG as SPI-master
Date: Thu, 17 Mar 2011 20:57:19 +0100

Hi, 

I'm playing with my TWOG to get the communication via SPI running. I'm using 
the following code to transmit some bytes to an arduino board. The problem is 
that only some bytes are received by the arduino, the number depends on the 
value of SSPCPSR_VAL, but unfortunately the all bytes never transmitted...

------code------
typedef struct {
        uint8_t iCmdID;
        uint8_t iDummy1;
        uint8_t iDummy2;
        uint8_t iDummy3;
        uint8_t iDummy4;
        uint8_t iDummy5;
        uint8_t iDummy6;
  } SPI_Message_t;

/* transmit buffer */
SPI_Message_t last_received_packet;
SPI_Message_t last_send_packet;

...

void ins_periodic_task( void ) {
  if (!SpiCheckAvailable()) {
    SpiOverRun();
    return;
  }

  last_send_packet.iCmdID  = 0x12;
  last_send_packet.iDummy1 = 0x13;
  last_send_packet.iDummy2 = 0x14;
  last_send_packet.iDummy1 = 0x15;
  last_send_packet.iDummy2 = 0x16;
  last_send_packet.iDummy1 = 0x17;
  last_send_packet.iDummy2 = 0x18;

  spi_buffer_input = (uint8_t*)&last_received_packet;
  spi_buffer_output = (uint8_t*)&last_send_packet;
  spi_buffer_length = sizeof(last_send_packet);
  SpiSelectSlave0();
  SpiStart();
}

-----end------------

The arduino receives only something like:
...
12
18
0
0
12
18
0
0
...

If I change the number of bytes, the pattern changes, most of the time at least 
the first byte fits. I'm pretty sure the arduino-slave works (I'm using just an 
ISR to print the received bytes.) Currently the ins_periodic_task() is called 
once a second...

Can anybody help? I did not found anything in the archive concerning such 
problems - or at least I did not find the right keywords ;-)

Thanks, 
Sven


reply via email to

[Prev in Thread] Current Thread [Next in Thread]