Your IOIO-side code looks OK. You can validate it by looping back MISO and
MOSI and see that you get the same value back (note that your current code
prints the request and not the response, which is possibly not what you
intended).

I haven't done SPI slave on the PIC, so I'm not sure whether or not your
code there is correct. One thing that appears to be missing is the
slave-select pin.


On Thu, Feb 13, 2014 at 9:37 AM, Aaron Lim <[email protected]> wrote:

> hello i am trying to establish SPI connection of IOIO with a PIC18f452
> microcontroller but had failed to do so. i wanted to send a series of value
> to the pic for processing for starter i try with a value to see my
> understanding of the process and operation is correct.
>
> This is the code of the IOIO side:
> public void loop() throws ConnectionLostException {
> spi = ioio_.openSpiMaster(12, 13, 14, 10, SpiMaster.Rate.RATE_1M);
>  byte0[0] = (byte) 127;
> byte1[0] = (byte) 0x00;
>  button1_.setOnClickListener(new OnClickListener() {
>  public void onClick(View view) {
> try {
> spi.writeRead(byte0, byte0.length, 1, byte1, byte1.length);
>  } catch (ConnectionLostException e) {
> e.printStackTrace();
> } catch (InterruptedException e) {
>  e.printStackTrace();
> }
> Toast.makeText(getApplicationContext(),String.valueOf(byte0[0]),
>  Toast.LENGTH_LONG).show();
> }
> });
>                       }
>
> And this is the code of the pic18f452 side:
>
> void main(void)
> {
>
> TRISD = 0x00;
> TRISA = 0xFF;
>  PORTD = 0x00;
> TRISCbits.TRISC3 = 1; //SCK clock
> TRISCbits.TRISC4 = 1; // DATA IN
>  TRISCbits.TRISC5 = 0; // DATA OUT
> OpenSPI(SLV_SSON, MODE_10, SMPMID);
> while(!DataRdySPI()); //check whether it is data at buffer bus is ready
>  resultant = SSPBUF;
> Delay10KTCYx(500);
> while(1)
> {
>  PORTD = resultant;
> Delay10KTCYx(500);
> }
> }
>
> i use LED at portd to check whether it is producing the result that i
> expected but it seems the PIC doesnt receive the data as the LED doesnt lit
> at all, i wonder is it the Mode and phase setting of the PIC cause this ?
>
> Please Help
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to