I am testing a custom board with TFT and SD card and the PIC57K42.
Good news is that I can get the TFT to work
But I can not get the SD card to init. Fat_MMC_init() always returns 255 regardless if I have the SD card attached or not.
I have other PCB using other 18F variants and they connect to the SD card in the same way on SPI1.
Connections:
Code: Select all
Pin nr Function on PIC Function on SD card
41 CLK SPI CLK
47 SDO SI data in
46 SDI SO data out
28 LATE.B1 CS
I can toggle all pins manually and measure high and low levels on the SD card pins so they are connected.
Does anybody spot any mistake or have a code that doesn't return 255 from init ... or I have to bring out the logical analyzer to see what is happening?
Code: Select all
char slask[20];
unsigned char test=0;
// TFT module connections
char TFT_16bit_DataPort_Lo at LATA;
char TFT_16bit_DataPort_Hi at LATD;
sbit TFT_16bit_RST at LATF.B2;
sbit TFT_16bit_BLED at LATC.B2;
sbit TFT_16bit_RS at LATC.B1;
sbit TFT_16bit_CS at LATE.B0;
sbit TFT_16bit_RD at LATF.B3;
sbit TFT_16bit_WR at LATE.B2;
char TFT_16bit_DataPort_Lo_Direction at TRISA;
char TFT_16bit_DataPort_Hi_Direction at TRISD;
sbit TFT_16bit_RST_Direction at TRISF.B2;
sbit TFT_16bit_BLED_Direction at TRISC.B2;
sbit TFT_16bit_RS_Direction at TRISC.B1;
sbit TFT_16bit_CS_Direction at TRISE.B0;
sbit TFT_16bit_RD_Direction at TRISF.B3;
sbit TFT_16bit_WR_Direction at TRISE.B2;
// End TFT module connections
// MMC/SD Connections
sbit Mmc_Chip_Select at LATE1_bit;
sbit Mmc_Chip_Select_Direction at TRISE1_bit;
// end of MMC/SD
void main() {
delay_ms(50);
TRISF.B0=0; // set STATUS LED PIN AS OUTPUT
TRISC.B2=0; // FORCE BACKLIGHT ON
LATC.B2=1; //
TFT_Init_ILI9481(320, 480);
delay_ms(10);
TFT_16bit_Fill_Screen(CL_YELLOW_16bit);
delay_ms(1000);
TFT_16bit_Write_Text("TFT 16-bit Library DEMO, WELCOME !", 0, 0);
delay_ms(1000);
Unlock_IOLOCK();
PPS_Mapping_NoLock(41, _OUTPUT, _SCK1);
PPS_Mapping_NoLock(47, _OUTPUT, _SDO1);
PPS_Mapping_NoLock(46, _INPUT, _SDI1);
Lock_IOLOCK();
SPI1_Remappable_Init_Advanced(_SPI_REMAPPABLE_MASTER_OSC_DIV64, _SPI_REMAPPABLE_DATA_SAMPLE_MIDDLE, _SPI_REMAPPABLE_CLK_IDLE_LOW, _SPI_REMAPPABLE_LOW_2_HIGH);
Delay_ms(10);
test=Mmc_Fat_Init();
delay_ms(1000);
bytetostr(test,slask);
delay_ms(1000);
TFT_16bit_Write_Text(slask, 0, 100);
delay_ms(1000);
//Start_TP();
while(1){
STAT_LED=~STAT_LED;
delay_ms(1000);
}