i want to use DSPI module of MPC5777C interfacing with EXTERNAL adc

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i want to use DSPI module of MPC5777C interfacing with EXTERNAL adc

1,945 Views
aadeshmukh5
Contributor II

i want to use DSPI module of MPC5777C interfacing with EXTERNAL adc , please help me for this

Tags (1)
10 Replies

1,673 Views
aadeshmukh5
Contributor II

Hello ,

i am using DSPI module , actually want to know about cs line, i have to wake cs line after 16th clock pulse , is there any sfr to control cs line in mpc5777c , or we have to manually make on or off it

please help me for this.

0 Kudos
Reply

1,673 Views
PetrS
NXP TechSupport
NXP TechSupport

CS line is controlled by the DSPI module according to CTARx setting and usage of PUSHR register.

CTAR registers define combinations of transfer attributes such as frame size, clock phase and polarity, data bit ordering, baud rate, and various delays. Within PUSHR's command word you specifies which CTAR is used. If also PUSHR[CONT] is cleared the CS line returns to inactive state between frames.

BR,

Petr

1,673 Views
aadeshmukh5
Contributor II

Hello petr,

thanks for this reply.

but i am not understanding how to set PCS bit in pushr register. can you please help me for this.means there are 6 pcs signal how to set it, and after that how to use this pushr[cont ] bit,

i want to make high cs line after 16 th clolck pulse , how to do it?

0 Kudos
Reply

1,673 Views
PetrS
NXP TechSupport
NXP TechSupport

you can use it this way...

static void SPI_Init(void)
{
   SPI_0.MCR.R = 0x80010001; /* Configure DSPI as master */
   SPI_0.MODE.CTAR[0].R = 0x78004445; /* Configure CTAR0, 16bit transfer */
   SPI_0.MCR.B.HALT = 0x0; /* Exit HALT mode: go from STOPPED to RUNNING state*/
}

static uint8_t Write_Byte(uint16_t cmd, uint16_t data)
{
   uint16_t response = 0x0000;

   SPI_0.PUSHR.PUSHR.R = (uint32_t)((uint32_t)(cmd<<16) + data); /**/
   while (SPI_0.SR.B.RFDF != 1){} /* Wait for Receive FIFO Drain Flag = 1 */
   response = (uint8_t)SPI_0.POPR.R; /* Read data received by master SPI */

   SPI_0.SR.R = 0x90020000;

   return((uint8_t)(0xFF & response));

}

Write_Byte(0x0001,0x1234);   // SPI0 sends word 0x1234 using CS0 as chip select

BR, Petr

1,673 Views
aadeshmukh5
Contributor II

thanks a lot petr,

it is working now as expected.

one more doubt , i am using DSPI_B module, i am reading data of external adc using SPI module,

i am using DSPI_B.POPR.R; for data reading, but not getting accurate, with this register, need to monitor any bit ?

0 Kudos
Reply

1,673 Views
PetrS
NXP TechSupport
NXP TechSupport

what did you mean by "not getting accurate"? The data read from POPR does not correspond to one on the SPI bus?

Or converted result is wrong. If the first one share screenshot of the frame on the SPI bus and the data read from POPR and the code you are using. If the latter one i have no hint.

BR, Petr

0 Kudos
Reply

1,673 Views
aadeshmukh5
Contributor II


send_data_cpld(0x0001,0x422B,0);

while(DSPI_B.SR.B.RFDF != 1){};
// while( DSPI_B.SR.B.TCF == 0){};
for(i=0;i<2;i++);
while(DRDY);

below is reading adc data from pop register
data1 = DSPI_B.POPR.R;
Result= data1 & 0xFFF0;

this is my code

0 Kudos
Reply

1,673 Views
aadeshmukh5
Contributor II

one more question petr,

while receiving data on MISO pin,. behaviour is little different , first data coming and then clock , is there any delay to set for incoming data??

0 Kudos
Reply

1,673 Views
PetrS
NXP TechSupport
NXP TechSupport

sorry do not understand, please explain on the bus signals you measured.

BR, Petr

0 Kudos
Reply

1,673 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

seems you already got hints for DSPI examples here:

https://community.nxp.com/thread/504713

We have nothing more, implement correct SPI communication with external chip is then application problem.

BR, Petr 

0 Kudos
Reply