1

I want to assign a pointer to a memory space to another register, like

DMA1_Channel4->CPAR = (uint32_t*)I2C2->TXDR;

elsewhere in my code i have used for example

DMA1_Channel4->CMAR  = (uint8_t*)DACdata;

which works, but gives a warning - assignment makes pointer from integer without a cast. however I don't know the correct syntax for the first instance

prune
  • 77
  • 1
  • 9
  • 1
    "assignment makes pointer from integer without a cast" means that you have to actually assign a pointer to an address, not to a value. Missing `&`. But in case a DMA register needs to store the address, you should be casting the address to an integer type, not a pointer type. – Lundin Oct 14 '20 at 09:23
  • General info: [“Pointer from integer/integer from pointer without a cast” issues](https://stackoverflow.com/questions/52186834/pointer-from-integer-integer-from-pointer-without-a-cast-issues). – Lundin Oct 14 '20 at 09:25

1 Answers1

2

The CPAR field of the DMA1_Channel4 structure most likely expects a value of type uint32_t, but you provide a value of type "pointer to uint32_t". Most likely you mean:

DMA1_Channel4->CPAR = (uint32_t)(&(I2C2->TXDR));

Note that I've added a "&" here, as you most likely want to put the address of the TXDR register of the second I2C bus into the CPAR field and not the current value itself.

Lundin
  • 195,001
  • 40
  • 254
  • 396
DCTLib
  • 1,016
  • 8
  • 22