我会尽量更清楚: 我需要将在RAM内存中计算出的3个浮点数转换为存储在RAM内存中不同位置的缓冲区:我编写了一个代码来执行此操作但是缓冲区没有以正确的方式填充:我只能读取一个值。这是RAM中用于计算var
的函数#pragma CODE_SECTION(Calculatevar,".FLASHCODE")
void Calculatevar(volatile signed char *a,volatile signed char *b,volatile signed char *c)
{
float axg, ayg, azg; // x, y, and z axis readings of the accelerometer
volatile unsigned char a_x,a_y,a_z;
axg = (ax + 2083)/16131.0;
ayg = (ay + 208)/16131.0;
azg = (az + 204)/16131.0;
*a=axg*126;
*b=ayg*126;
*c=azg*126;
}
在main()中我写了Calculatevar(& a,& b,& c);定义volatile signed char a,b,c; 这是DMA功能:
unsigned char DMA_transfer(buffer *pointer_buffer) //DATA WRITE/PUSH
{ int next = pointer_buffer->head + 1;
if (next >= pointer_buffer->Num_Samples)
next = 0;
//buffer is full
DMA0SZ =pointer_buffer->Num_Samples;
// __data20_write_long((unsigned long) &DMA0SA,(unsigned long) &d1);
__data20_write_long((unsigned long) &DMA0SA,(unsigned long) & a);
__data20_write_long((unsigned long) &DMA0DA,(unsigned long) &pointer_buffer->buffer[pointer_buffer->head]);
DMA0CTL |= DMAEN +DMAIE; // Enable DMA0
DMA0CTL |= DMAREQ; // Trigger block transfer
pointer_buffer->head = next;
return 0;
}
我错过了什么?
答案 0 :(得分:0)
对于初学者来说,第一个片段与DMA无关,并显示存储3个字符而不是浮点数。
其次,没有代码设置块传输,源/目标地址更改或字节(与字)传输。
如果没有其他代码配置DMA0,则一个字的默认单一传输模式只能正确传输一个值,因为在每个DMA0SZ传输次数后,源地址和目标地址都不会递增。