I am new to the Tiva Launchpad and I am working using the TM4C129 launchpad. I want to transfer some data (an array of 64 8-bit elements) using uDMA and the SSI transmit FIFO. I have never done uDMA before so I am not entirely sure if my understanding is correct. I want to transfer the data from the launchpad over SPI to an mbed board which is set up as an SPI slave. As a result, I have tried to configure SSI1 for use on uDMA Channel 11. I have the following code but cannot seem to transfer anything?
#include "spi.h"
uint32_t ucControlTable[256] __attribute__ ((aligned(1024)));
#define CH11PR (11*4)
#define CH11ALT (11*4+128)
#define SSI1_DR ((volatile uint32_t *)0x40009008)
uint8_t *SourcePt;
volatile uint32_t *DestinationPt;
void SPI_Init(void){
SYSCTL->RCGCSSI |= (1UL<<1);
SYSCTL->RCGCGPIO |= (1UL<<1);
SYSCTL->RCGCGPIO |= (1UL<<4);
while((SYSCTL->PRGPIO&(1UL<<1)) == 0){};
GPIOB_AHB->AFSEL |= ((1UL<<5)|(1UL<<4));
GPIOE_AHB->AFSEL |= ((1UL<<5)|(1UL<<4));
GPIOB_AHB->DEN |= ((1UL<<5)|(1UL<<4));
GPIOE_AHB->DEN |= ((1UL<<5)|(1UL<<4));
GPIOB_AHB->PCTL = (GPIOB_AHB->PCTL&0xFF00FFFF)+0x00FF0000;
GPIOE_AHB->PCTL = (GPIOE_AHB->PCTL&0xFF00FFFF)+0x00FF0000;
GPIOB_AHB->AMSEL = 0;
GPIOE_AHB->AMSEL = 0;
SSI1->CR1 &=~ (1UL<<1);
SSI1->CR1 &=~ (1UL<<2);
SSI1->CPSR = (SSI1->CPSR&~0x000000FF )+120;
SSI1->CR0 &= ~(0x0000FF00 |
0x00000080 |
0x00000040);
SSI1->CR0 = (SSI1->CR0&~0x30)+0;
SSI1->CR0 = (SSI1->CR0&~0xF)+0x7;
}
void DMA_SPI_Init (void){
int i;
volatile uint32_t delay;
for(i=0; i<256; i++){
ucControlTable[i] = 0;
}
SYSCTL->RCGCDMA = 0x01;
delay = SYSCTL->RCGCDMA;
UDMA->CFG = 0x01;
UDMA->CTLBASE = (uint32_t)ucControlTable;
UDMA->CHMAP1 = (UDMA->CHMAP1&0xFFFF00FF)|0x00001100;
UDMA->PRIOCLR = ((1UL<<11)|(1UL<<10));
UDMA->ALTCLR = ((1UL<<11)|(1UL<<10));
UDMA->USEBURSTCLR = ((1UL<<11)|(1UL<<10));
UDMA->REQMASKCLR = ((1UL<<11)|(1UL<<10));
}
void SPI_Interrupt_Enable(void){
SSI1->IM =(1UL<<5);
SSI1->DMACTL =((1UL<<1)|(1UL<<0));
NVIC_EnableIRQ(SSI1_IRQn);
SSI1->CR1 |= 0X2;
}
void static setRegular(void){
ucControlTable[CH11PR] = (uint32_t)SourcePt;
ucControlTable[CH11PR+1] = (uint32_t)DestinationPt;
ucControlTable[CH11PR+2] = 0xC00083F1;
/* DMACHCTL Bits Value Description
DSTINC 31:30 11 no destination address increment
DSTSIZE 29:28 00 8-bit destination data size
SRCINC 27:26 00 8-bit source address increment
SRCSIZE 25:24 00 8-bit source data size
reserved 23:18 000000 N/A
ARBSIZE 17:14 0010 Arbitrates after 4 transfer
XFERSIZE 13:4 0000111111 Transfer count items
NXTUSEBURST 3 0 N/A
XFERMODE 2:0 001 Use basic transfer mode
*/
}
void DMA_Start(uint8_t *source){
SourcePt = source+63 ;
DestinationPt = SSI1_DR;
setRegular();
SPI_Interrupt_Enable();
UDMA->ENASET |= (1UL<<11);
}
void DMA_Stop(void){
UDMA->ENACLR = (1UL<<11);
NVIC_DisableIRQ(SSI1_IRQn);
}
void SSI1_Handler (void){
SSI1->DMACTL &=~(1UL<<1);
SSI1->ICR = (1UL<<5);
DMA_Stop();
}
And my main function simple does the following:
#include "definitions.h"
#include "spi.h"
uint8_t Test[64];
int main (void){
int i;
PLL_Init();
SysTick_Init();
UART_Init();
SPI_Init();
DMA_SPI_Init();
printf ("this is a simple dma spi test:");
for(i=0;i<64;i++){
Test[i]=i;
}
Delay_ms(1);
DMA_Start(Test);
while(1){
}
}
Any help would be greatly appreciated.