Hi,
I used CAN RAM to store certain data to survive TCM RAMs PBIST&Init... CAN RAM worked well when I had a small amount (8 bytes) of data to store, then I figured after testing and extensive reading of data sheet & TRM that usage of peripheral RAMs is not so trivial as it first seemed based on the data sheet...
Looks like also that using TCM RAM is not possible even with linker mapping because SL_Init_Memory() only has 1 argument descriptor (RAMTYPE_RAM) for whole TCM RAM. PBIST has splitted the RAM in half PBIST_RAMGROUP_06_ESRAM1 and PBIST_RAMGROUP_21_ESRAM5 so PBISTin should be doable but not initialization.
- So it is not possible to reserve space with linker from ESRAM1 to normally hold the struct to be backupped and then manually copy it to ESRAM5 and then do PBIST & memoryinit for ESRAM1 and copy the backupped data back to ESRAM1 and then make PBIST & init for ESRAM5
It this interpretation correct for peripheral RAMs concerning CAN, ADC & N2HET (just checked a couple of them)?
CAN3: 0xFF1A_0000 - 0xFF1B_FFFF, actual size 2KB (wrap around if unimplemented address)
- this means that you need to dig out from TRM how much of that 2KB block is implemented and how it is implemented
- TRM 24.5.4: Looks like that every message object (0x20 size == 8*32bit) only the first 4 32bit blocks can be written, offset 0x10 allows also lsb byte to be written and rest of it is more or less reserved
- So one message object can "easily" store 16 bytes (4x32bit) if not counting that lsb byte from 0x10 offset.
- CAN looks to have 64 message objects to total storage space 64*16bytes=1024 and every other 16byte area must be skipped when writing & reading
I assume that in RDA mode the TRM 24.5.2 mention about message object64 (address 0x0000) is meaningless and also that part of the RAM can be used freely....
What TRM 24.5.4 means "The CPU has access to one word line at a time only.", looks to be possible to write 32bit at once like this
sl_canREG3->CTL = 0x00000481U; /* Disable parity, TEST mode, init mode, */
sl_canREG3->TEST = 0x00000200U; /* Enable RAM Direct Access mode */
#define canRAM3_PTR ((volatile uint32 *)0xFF1A0000U)
*(canRAM3_PTR+0) = 0xAABBCCDD;
And also it looks like to be possible to write with 8bit pointer byte by byte
#define canRAM3_PTR_8bit ((volatile uint8 *)0xFF1A0000U)
*(canRAM3_PTR_8bit+0) = 0x11;
*(canRAM3_PTR_8bit+1) = 0x22;
*(canRAM3_PTR_8bit+2) = 0x33;
*(canRAM3_PTR_8bit+3) = 0x44;
*(canRAM3_PTR_8bit+4) = 0x55;
*(canRAM3_PTR_8bit+5) = 0x66;
*(canRAM3_PTR_8bit+6) = 0x77;
ADC2: 0xFF3A_0000 - 0xFF3B_FFFF, actual size 8KB (wrap around if unimplemented address)
- this means that you need to dig out from TRM how much of that 2KB block is implemented and how it is implemented
- looks like 64 channels == 64*32bit address and only lower 16 bit of each 32bit datafield can be written, upper 16bit is always 0
- Total data storage 64*2bytes == 128 bytes if using 16-bit data packing and 64bytes if writing only lsb byte.
TRM 20.9.2: "Only 32-bit reads and writes are allowed to the ADC results RAM in this test mode."
- this prevents writing byte by byte
N2HET: Then I though that N2HET would be at least "full consecutive ram" but looks like that it isn't either and has also some accessing restrictions
TRM 21.2.2.1: only 32 bit writes allowed, every 4th address is reserved which should not be accessed
As it looks to require rather deep looking to find out properties of each peripheral RAM I think that CAN RAM is rather easy to use and quite much data can be stored, just make a structure for the you want to store and then store it manually (almost like memcpy()) byte by byte by using 8bit pointer and when 16 bytes are stored increase ten destination pointer by 16 to skip that "reserved area of message object" and repeat until out of data. Restoring the data from CAN RAM should be as easy by using same 8 bit pointer. Only limitation is that implemented area which means 1024bytes which is rather large, if more data is stored and beginning of the data is over written.
- is this correct, and there is no need to wait anything when init mode bit is set in CTL register?
- since this is safety related data, CRC from the data should be calculated and added to end of actual data or at least use parity checking in CAN RAM (but would it require memory init for CAN RAM first if not writing full 32bit blocks with 8 bit pointer)?
Will there be more simpler peripherals RAMs to use for backupping the data which is in both RM44 & RM48 series? Didn't look about VIMRAM because in case of debugger reset at least FIQ can come through so don't want to corrupt vectors...