AnsweredAssumed Answered

SPI 3 as Slave dma not working on MPC5748G

Question asked by Zubair Ahmed on Sep 12, 2018

Hi all,

         I have my SPI_3 configured as slave. It works fine for RX case while it is not working as Tx mode. 

 

I want to transmit 2 byte data in each minor loop using SPI_3 which is working as slave. Here is my configuration. Please suggest correct way out for 2 byte data on each transfer over SPI as I want to receive 2 byte and give back 2 byte of data. 

const uint16_t TransmitBuffer[] =
{
(0| 0x5555), ( 1 | 0x0001), ( 2 | 0x0001), ( 3 | 0x0001),
( 4 | 0x0001), ( 5 | 0x0001), ( 6 | 0x0001), ( 7 | 0x0001),
( 8 | 0x0001), ( 9 | 0x0001), ( 10 | 0x0001), ( 11 | 0x0001),
( 12 | 0x0001), ( 13 | 0x0001), ( 14 | 0x0001), ( 15 | 0x0001),
( 16 | 0x0001), ( 17 | 0x0001), ( 18 | 0x0001), ( 19 | 0x0001),
( 20 | 0x0001), ( 21 | 0x0001), ( 22 | 0x0001), ( 23 | 0x0001),
( 24 | 0x0001), ( 25 | 0x0001), ( 26 | 0x0001), ( 27 | 0x0001),
( 28 | 0x0001), ( 29 | 0x0001), ( 30 | 0x0001), ( 31 | 0x0001),
( 32 | 0x0001), ( 33 | 0x0001), ( 34 | 0x0001), ( 35 | 0x0001),
( 36 | 0x0001), ( 37 | 0x0001), ( 38 | 0x0001), ( 39 | 0x0001),
( 40 | 0x0001), ( 41 | 0x0001), ( 42 | 0x0001), ( 43 | 0x0001),
( 44 | 0x0001), ( 45 | 0x0001), ( 46 | 0x0001), ( 47 | 0x0001),
( 48 | 0x0001), ( 49 | 0x0001), ( 50 | 0x0001), ( 51 | 0x0001),
( 52 | 0x0001), ( 53 | 0x0001), ( 54 | 0x0001), ( 55 | 0x0001),
( 56 | 0x0001), ( 57 | 0x0001), ( 58 | 0x0001), ( 59 | 0x0001),
( 60 | 0x0001), ( 61 | 0x0001), ( 62 | 0x0001), ( 63 | 0x0001),
( 64 | 0x0001), ( 65 | 0x0001), ( 66 | 0x0001), ( 67 | 0x0001),
( 68 | 0x0001), ( 69 | 0x0001), ( 70 | 0x0001), ( 71 | 0x0001),
( 72 | 0x0001), ( 73 | 0x0001), ( 74 | 0x0001), ( 75 | 0x0001),
( 76 | 0x0001), ( 77 | 0x0001), ( 78 | 0x0001), ( 79 | 0x0001),
( 80 | 0x0001), ( 81 | 0x0001), ( 82 | 0x0001), ( 83 | 0x0001),
( 84 | 0x0001), ( 85 | 0x0001), ( 86 | 0x0001), ( 87 | 0x0001),
( 88 | 0x0001), ( 89 | 0x0001), ( 90 | 0x0001), ( 91 | 0x0001),
( 92 | 0x0001), ( 93 | 0x0001), ( 94 | 0x0001), ( 95 | 0x0001),
( 96 | 0x0001), ( 97 | 0x0001), ( 98 | 0x0001), ( 99 | 0x0001),
(100 | 0x0001), (101 | 0x0001), (102 | 0x0001), (103 | 0x0001),
(104 | 0x0001), (105 | 0x0001), (106 | 0x0001), (107 | 0x0001),
(108 | 0x0001), (109 | 0x0001), (110 | 0x0001), (111 | 0x0001),
(112 | 0x0001), (113 | 0x0001), (114 | 0x0001), (115 | 0x0001),
(116 | 0x0001), (117 | 0x0001), (118 | 0x0001), (119 | 0x0001),
(120 | 0x0001), (121 | 0x0001), (122 | 0x0001), (123 | 0x0001),
(124 | 0x0001), (125 | 0x0001), (126 | 0x0001), (127 | 0x0001),
(128 | 0x0001), (120 | 0x0001), (130 | 0x0001), (131 | 0x0001),
(132 | 0x0001), (133 | 0x0001), (134 | 0x0001), (135 | 0x0001),
(136 | 0x0001), (137 | 0x0001), (138 | 0x0001), (139 | 0x0001),
(140 | 0x0001), (141 | 0x0001), (142 | 0x0001), (143 | 0x0001),
(144 | 0x0001), (145 | 0x0001), (146 | 0x0001), (147 | 0x0001),
(148 | 0x0001), (149 | 0x0001), (150 | 0x0001), (151 | 0x0001),
(152 | 0x0001), (153 | 0x0001), (154 | 0x0001), (155 | 0x0001),
(156 | 0x0001), (157 | 0x0001), (158 | 0x0001), (159 | 0x0001),
(160 | 0x0001), (161 | 0x0001), (162 | 0x0001), (163 | 0x0001),
(154 | 0x0001), (165 | 0x0001), (166 | 0x0001), (167 | 0x0001),
(168 | 0x0001), (169 | 0x0001), (170 | 0x0001), (171 | 0x0001),
(172 | 0x0001), (173 | 0x0001), (174 | 0x0001), (175 | 0x0001),
(176 | 0x0001), (177 | 0x0001), (178 | 0x0001), (179 | 0x0001),
(180 | 0x0001), (181 | 0x0001), (182 | 0x0001), (183 | 0x0001),
(184 | 0x0001), (185 | 0x0001), (186 | 0x0001), (187 | 0x0001),
(188 | 0x0001), (189 | 0x0001), (190 | 0x0001), (191 | 0x0001),
(192 | 0x0001), (193 | 0x0001), (194 | 0x0001), (195 | 0x0001),
(196 | 0x0001), (197 | 0x0001), (198 | 0x0001), (199 | 0x0001),
(200 | 0x0001), (201 | 0x0001), (201 | 0x0001), (203 | 0x0001),
(204 | 0x0001), (205 | 0x0001), (206 | 0x0001), (207 | 0x0001),
(208 | 0x0001), (209 | 0x0001), (210 | 0x0001), (211 | 0x0001),
(212 | 0x0001), (213 | 0x0001), (214 | 0x0001), (215 | 0x0001),
(216 | 0x0001), (217 | 0x0001), (218 | 0x0001), (219 | 0x0001),
(220 | 0x0001), (221 | 0x0001), (222 | 0x0001), (223 | 0x0001),
(224 | 0x0001), (225 | 0x0001), (226 | 0x0001), (227 | 0x0001),
(228 | 0x0001), (229 | 0x0001), (230 | 0x0001), (231 | 0x0001),
(232 | 0x0001), (233 | 0x0001), (234 | 0x0001), (235 | 0x0001),
(236 | 0x0001), (237 | 0x0001), (238 | 0x0001), (239 | 0x0001),
(240 | 0x0001), (241 | 0x0001), (242 | 0x0001), (243 | 0x0001),
(244 | 0x0001), (245 | 0x0001), (246 | 0x0001), (247 | 0x0001),
(248 | 0x0001), (249 | 0x0001), (250 | 0x0001), (251 | 0x0001)
};

EDMA.TCD[17].SADDR.R = (uint32_t )&TransmitBuffer; /* Source address */
EDMA.TCD[17].ATTR.B.SSIZE = 2; /* Read 2**2 = 4 bytes per transfer */
EDMA.TCD[17].ATTR.B.SMOD = 0; /* Source modulo feature not used */
EDMA.TCD[17].SOFF.R = 2; /* After transfer, add 2 to src addr */
EDMA.TCD[17].SLAST.R = 0; /* No addr adjustment after major loop */

EDMA.TCD[17].DADDR.R = (uint32_t )&SPI_3.PUSHR.PUSHR.R; /* Destination address */
EDMA.TCD[17].ATTR.B.DSIZE = 2; /* Write 2**2 = 4 byte per transfer */
EDMA.TCD[17].ATTR.B.DMOD = 0; /* Destination modulo feature not used */
EDMA.TCD[17].DOFF.R = 0; /* No addr adjustment after major loop */
/* If repeating major loop, subtract NUMBER_OF_BYTES from dest. addr. */
EDMA.TCD[17].DLASTSGA.R = 0; /* After major loop, adjust the destination address */

/* If repeating major loop, set this to 0 to keep the channel enabled */
EDMA.TCD[17].CSR.B.DREQ = 1; /* Disable channel when major loop is done*/
EDMA.TCD[17].NBYTES.MLNO.R = 2; /* NBYTES - Transfer 1 byte per minor loop */
EDMA.TCD[17].CITER.ELINKNO.B.ELINK = 0; /* No Enabling channel LINKing */
EDMA.TCD[17].CITER.ELINKNO.B.CITER = 126; /* Init. current interaction count */
EDMA.TCD[17].BITER.ELINKNO.B.ELINK = 0; /* No Enabling channel LINKing */
EDMA.TCD[17].BITER.ELINKNO.B.BITER = 126; /* Minor loop iterations */
EDMA.TCD[17].CSR.B.MAJORELINK = 0; /* Dynamic program is not used */
EDMA.TCD[17].CSR.B.ESG = 0; /* Scatter Gather not Enabled */
EDMA.TCD[17].CSR.B.BWC = 0; /* Default bandwidth control- no stalls */
EDMA.TCD[17].CSR.B.INTHALF = 0; /* No interrupt when major count half complete */
EDMA.TCD[17].CSR.B.INTMAJOR = 1; /* No interrupt when major count completes */
EDMA.TCD[17].CSR.B.MAJORLINKCH = 0; /* No link channel # used */
EDMA.TCD[17].CSR.B.START = 0; /* Initialize status flags START, DONE, ACTIVE */
EDMA.TCD[17].CSR.B.DONE = 0;
EDMA.TCD[17].CSR.B.ACTIVE = 0;

 

 

Anxiously waiting for your response. 

Outcomes