2015-11-27 01:38 PM
I am trying to perform a memory read operation in a STM32L152 discovery board using the following code:
#include ''stm32l1xx.h''#include ''stdio.h''uint16_t ts_cal1;uint32_t address1=0x1FF800FB;uint32_t address2=0x1FF800FE;ts_cal1 = *((uint16_t*)address1);I am getting several errors in the fourth lineError[Pe077]: this declaration has no storage class or type specifierError[Pe147]: declaration is incompatible with ''uint16_t ts_cal1'' (declared at line 4) Error[Pe028]: expression must have a constant value I am not sure whether this is an IAR configuration error or not. Any suggestions will be appreciated.2015-11-27 03:15 PM
Probably objecting to the ODD address?
And that the code is rather formless, don't think you can do assignments like that. #include ''stm32l1xx.h'' #include ''stdio.h'' uint32_t address1=0x1FF800FA; uint16_t ts_cal1 = *((uint16_t*)address1);2015-11-28 12:38 AM
void SRAM_ReadBuffer(uint16_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBufferSize)
{
__IO uint32_t write_pointer = (uint32_t)uwReadAddress;
for (; uwBufferSize != 0; uwBufferSize--)
{
/* Read a half-word from the memory */
*pBuffer++ = *(__IO uint16_t*) (SRAM_BANK_ADDR + write_pointer);
/* Increment the address*/
write_pointer += 2;
}
This is example how to read from memory space, where that space represents external SRAM