Pumpkin, Inc.

Pumpkin User Forums

Setting SPI Connection

If you have a general question or comment regarding the CubeSat kit, post it here.

Setting SPI Connection

Postby balvisio » Sun Apr 24, 2011 8:15 pm

Hi,

I am trying to connect the CubeSat to a Magnetometer. I am using PPM D1 with PIC24FJ256GA110.
My code to setup an SPI connection (through SPI2) + two handshaking signals (one is an input: RD3 and one is an output: RD8). is the following:

--------------------------------
#define MAG_DRDY_PORT PORTDbits.RD3
#define MAG_RST_PORT PORTDbits.RD8
#define MAG_TRIS_DRDY_PORT TRISDbits.TRISD3
#define MAG_TRIS_RST_PORT TRISDbits.TRISD8

PPSUnLock;

//Input
PPSInput(PPS_SDI2, PPS_RP26);

//Output
//PPS and IPPS are equivalent
PPSOutput(PPS_RP21, PPS_SCK2OUT);
PPSOutput(PPS_RP19, PPS_SDO2);
PPSOutput(PPS_RP27, PPS_SS2OUT);
PPSLock;


MAG_TRIS_RST_PORT = 0x0; // set reset port to be an output
MAG_TRIS_DRDY_PORT = 0x1; // set data ready port to be an input


----------------------------------------------------------------------------------------
I also wrote some code for writing and reading to the magnetometer.

With this set-up code, I see in the oscope the MISO (master in slave out) going out of the magnetometer varying between 0V (low) and 4V (high). However, as soon as I connect the line to the cubeSat bus the signal almost disappears. (Goes from 0V to 0.3 V).
Given that I set up RP26 to be the MISO of SPI2 I am connecting this line to I.O. 10 of the motherboard.

Does anybody has an idea on why the MISO signal disappears when I plug it into the bus?

BTW,
The DRDY_PORT is connected to I.O. 17 of MB
The RESET_PORT is connected to I.O. 16 of MB

Thanks,

Bruno
balvisio
 
Posts: 6
Joined: Sat Apr 02, 2011 1:53 pm

Re: Setting SPI Connection

Postby aek » Wed Apr 27, 2011 6:58 am

Hi Bruno.

I'm not going to debug your code, but I can tell you that there is working SPI code in the CubeSat Kit software associated with the EFFS-THIN SD Card software. So you can look at it as a reference in terms of configuring the various PPS pins, and running the SPI.

Be sure to use an SPI that is higher than the one normally used by the EFFS-THIN software -- IIRC you have three to choose from. The CSK uses the lowest / first one for the SD Card.

Also, assuming you're using a MicroMag 3, its implementation of SPI is a little unusual, and you'll need to fully understand what they're trying to say in the datasheet before getting it to work ...
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to CubeSat General

Who is online

Users browsing this forum: No registered users and 2 guests

cron