Pic32MZ Spi slave interrupt

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
moxadesign
Posts: 2
Joined: 15 Sep 2014 07:17

Pic32MZ Spi slave interrupt

#1 Post by moxadesign » 15 Sep 2019 16:01

Hi,
i need to have a pic32MZ2048EFM144 in SPI slave mode. The mcu need to read data from another CPU (not PIC) which is set to master mode.
I have try some code solutions and flag settings but i'm not able to work with this interrupt.
I attach the simplified last code writed for explain my need.
Can you help me?
Thank's.
PS: i'm sure which i make a coding error, it's the first time which i use PIC32 and multivector mode..

//****************************************************************************
// INTERRUPT SECTION
//****************************************************************************
void Spi6rx_interrupt() iv IVT_SPI6_RX ilevel 7 ics ICS_SRS{
SPI6RXIF_bit = 0;
SPI6IF_bit = 0;
}
//****************************************************************************
// services routine section
//****************************************************************************
void InitMain() {
SPI6_Init_Advanced(_SPI_SLAVE,_SPI_8_BIT,2,_SPI_SS_ENABLE,_SPI_DATA_SAMPLE_END,_SPI_CLK_IDLE_HIGH,_SPI_ACTIVE_2_IDLE);
Delay_ms(100);
}

void io_mapping(){
Unlock_IOLOCK();
PPS_Mapping(_RPF8,_OUTPUT,_SDO6); // SPI CHANNEL 6
PPS_Mapping(_RPF2,_INPUT,_SDI6); // SPI CHANNEL 6
PPS_Mapping(_RPD14,_INPUT,_SS6_IN); // SPI 6 CHANNEL SLAVE SELECT
Lock_IOLOCK();
}
//****************************************************************************
// MAIN PROGRAM SECTION
//****************************************************************************
void main() {
// disable all analog inputs
ANSELA=0;
ANSELB=0;
ANSELC=0;
ANSELD=0;
ANSELE=0;
ANSELF=0;
ANSELG=0;
ANSELH=0;
ANSELJ=0;

// define input and output map
io_mapping();
initMain();
gearIO();
// prepare interrupt flags
// spi channel 6
IFS5 = 0;
SPI6RXIF_bit=0;
SPI6EIP0_bit = 1;
SPI6EIP1_bit = 1;
SPI6EIP2_bit = 1;
SPI6RXIS0_bit = 1;
SPI6RXIS1_bit = 0;
EnableInterrupts(); // internal function which enable interrupt services
// spi channel 6
SPI6IE_bit=1;
SPI6RXIE_bit=1;
//****************************************************************************
// MAIN LOOP
//****************************************************************************
while (1){
gear();
}

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Pic32MZ Spi slave interrupt

#2 Post by filip.grujcic » 16 Sep 2019 16:30

Hi,

Could you zip and attach the entire project please?

Kind regards,
Filip Grujcic

moxadesign
Posts: 2
Joined: 15 Sep 2014 07:17

Re: Pic32MZ Spi slave interrupt

#3 Post by moxadesign » 16 Sep 2019 17:36

This is the entire project which differ from the previous listed because i'have try more and more attemps without finding solution. Any help is good.
Thank's
Attachments
ProvaPIC32.zip
(228.22 KiB) Downloaded 79 times

Post Reply

Return to “mikroC PRO for PIC32 General”