[fpc-pascal] FPC Embedded DMA with STM32?

turro75 valerio.turrini at gmail.com
Sun May 10 02:21:27 CEST 2015


Update:

I solved by declaring individual registers as absolute.
I need the help of some fpc guru to understand why I got the problem.

According to stm32 manual I declared the same register in two ways:
/ 
TDMAChannel = record
  CCR,
  CNDTR,
  CPAR,
  CMAR :longword;
 end;        


DMA1_Channel1 : TDMAChannel                         absolute ($40020008);
dma1_ccr1 : longword   absolute($40020008);
dma1_cndtr1 : longword   absolute($4002000C);
dma1_cpar1 : longword   absolute($40020010);
dma1_cmar1 : longword   absolute($40020014);    /

I put some values to the serial port to understand what is happening:

/Serial1.println;
  Serial1.print('0x'+hexstr(longword(@DMA1_Channel1.CCR),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_CCR1),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_Channel1.CNDTR),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_CNDTR1),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_Channel1.CPAR),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_CPAR1),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_Channel1.CMAR),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_CMAR1),8));
  Serial1.println;   /             

this is the output:
0x40020008 0x40020008 0x4002000C 0x4002000C 0x40020010 0x40020010 0x40020014
0x40020014

so address are exactly the same

if I remove the @ I should get the value of the register:

 / Serial1.println;
  Serial1.print('0x'+hexstr(longword(@DMA1_Channel1.CCR),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_CCR1),8));
  Serial1.print(' 0x'+hexstr(longword(@DMA1_Channel1.CNDTR),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_CNDTR1),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_Channel1.CPAR),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_CPAR1),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_Channel1.CMAR),8));
  Serial1.print(' 0x'+hexstr(longword(DMA1_CMAR1),8));
  Serial1.println;  /    

this is the output:
0x40020008 0x00005A61 0x4002000C 0x0000000D 0x200002F4 0x200002F4 0x40010810
0x40010810

If I remove also the @ from /Serial1.print('
0x'+hexstr(longword(@DMA1_Channel1.CNDTR),8));/

this is the output:
0x40020008 0x00005A61

the program stops running when trying to access this register, it does the
same with DMA1_Channel1.CCR.
what makes me mad is that the other 2 registers are well working and in the
stm32f103fw unit there are a lot of registers which work fine with the
record declaration.

Any idea?



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/FPC-Embedded-DMA-with-STM32-tp5721684p5721685.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list