• AVR Freaks

Harmony FS sdcard questions

Author
skaptor
n00b member
  • Total Posts : 248
  • Reward points : 0
  • Joined: 2012/07/25 11:18:48
  • Location: Tilted Towers
  • Status: offline
2014/12/09 13:36:33 (permalink)
0

Harmony FS sdcard questions

Hello,
 
Like many others in this forum, I am struggling with Harmony.
 
I'm trying to port the sdcard_fat_single_disk demo onto my ChipKit Wifire (MZ) board.
 
The main problem has to do with the SD detection logic since the ChipKit doesn't have a physical card-detect pin. Anyways, after remapping the RP pins and changing all the drivers to the SPI3 module I still have many questions and I hope someone could help me out.
 
1.- Is there a way to use the software detect? I
2.- I've measured the SPI2 signals with my scope and they seem to be working well, but (again) the ChipKit has the SD socket connected to the SPI3 module.
 
The pins are correctly remapped using the library functions.
 
I've modified the SD Card driver to this:
 

/*** SDCARD Driver Initialization Data ***/
const DRV_SDCARD_INIT drvSDCardInit =
{
// .spiId = SPI_ID_2,
    .spiId = SPI_ID_3,
    .spiIndex = 0,
    .sdcardSpeedHz = 20000000,
    .spiClk = CLK_BUS_PERIPHERAL_2,
    .sdCardPinActiveLogic = SDCARD_DETECTION_LOGIC_ACTIVE_LOW,
    .cardDetectPort = PORT_CHANNEL_A,
    .cardDetectBitPosition = BSP_SWITCH_1, //ChipKit sw1
    .writeProtectPort = PORT_CHANNEL_A,
    .writeProtectBitPosition = BSP_SWITCH_2,//ChipKit sw2
    .chipSelectPort = PORT_CHANNEL_C,
    .chipSelectBitPosition = PORTS_BIT_POS_3,
};

 
Also the SPI Driver & SPI ISRs:
 

/*** SPI Driver Initialization Data ***/
/*** Index 0  ***/
DRV_SPI_INIT drvSpi0InitData =
{
    .spiId = SPI_ID_3,
    .taskMode = DRV_SPI_TASK_MODE_ISR,
    .spiMode = DRV_SPI_MODE_MASTER,
    .allowIdleRun = 0,
    .spiProtocolType = DRV_SPI_PROTOCOL_TYPE_STANDARD,
    .commWidth = SPI_COMMUNICATION_WIDTH_8BITS,
    .spiClk = CLK_BUS_PERIPHERAL_2,
    .baudRate = 20000000,
    .bufferType = DRV_SPI_BUFFER_TYPE_STANDARD,
    .clockMode = DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL,
    .inputSamplePhase = SPI_INPUT_SAMPLING_PHASE_AT_END,
    .txInterruptSource = INT_SOURCE_SPI_3_TRANSMIT,
    .rxInterruptSource = INT_SOURCE_SPI_3_RECEIVE,
    .errInterruptSource = INT_SOURCE_SPI_3_ERROR,
    .queueSize = 10,
    .jobQueueReserveSize = 1,
};
 
 void __ISR(_SPI3_RX_VECTOR, ipl3) _IntHandlerSPIRxInstance0(void)
{
    DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}
void __ISR(_SPI3_TX_VECTOR, ipl3) _IntHandlerSPITxInstance0(void)
{
    DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}
void __ISR(_SPI3_FAULT_VECTOR, ipl3) _IntHandlerSPIFAultInstance0(void)
{
    DRV_SPI_Tasks(sysObj.spiObjectIdx0);
}

 
Is this the correct way of changing the SPI module? Am I missing something?

Porsche 718 Cayman GTS
#1
prem999
Super Member
  • Total Posts : 257
  • Reward points : 0
  • Joined: 2013/03/27 22:03:51
  • Location: 0
  • Status: offline
Re: Harmony FS sdcard questions 2014/12/09 21:38:50 (permalink)
0
1. The SD card soft detection is not tested in Harmony AFAIK.
2. I think you should use the MPLAB Harmony configurator (MHC) to change from SPI2 to SPI3. When you change the settings in MHC you can generate the code from it, thats how all the demos have been generated.
#2
skaptor
n00b member
  • Total Posts : 248
  • Reward points : 0
  • Joined: 2012/07/25 11:18:48
  • Location: Tilted Towers
  • Status: offline
Re: Harmony FS sdcard questions 2014/12/16 09:06:30 (permalink)
3 (1)
Thank you for your reply,
 
I usually don't use the software detect, but well, I will have to emulate it with a switch.
 
Can you provide me with a link to get started with MHC?
 
EDIT:
 
nvm I just updated MHC to 0.8 and it works fine.
 
post edited by Skaptor - 2014/12/16 09:24:35

Porsche 718 Cayman GTS
#3
freebsd
Super Member
  • Total Posts : 156
  • Reward points : 0
  • Joined: 2011/03/07 04:15:29
  • Location: 0
  • Status: offline
Re: Harmony FS sdcard questions 2014/12/17 00:35:47 (permalink)
0
Hi ,
You can get the MHC configuration detail form the help_harmony.pdf.
"MPLAB Harmony Configurator (MHC) Help "  is part of the utilities help section.
#4
skaptor
n00b member
  • Total Posts : 248
  • Reward points : 0
  • Joined: 2012/07/25 11:18:48
  • Location: Tilted Towers
  • Status: offline
Re: Harmony FS sdcard questions 2014/12/18 15:15:34 (permalink)
0
Hi,
 
Tthank you for the info,
 
I was able to do the required config by updating MHC to version 0.8, but still I've had no success.
 
regards

Porsche 718 Cayman GTS
#5
Jump to:
© 2019 APG vNext Commercial Version 4.5