energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
798 stars 670 forks source link

Accessing msp430's upper 64KB memory banks #947

Closed dazhbog closed 7 years ago

dazhbog commented 7 years ago

Hi there!

I have been trying for a while to use the upper bank C and bank D memory areas on my MSP430F5529. Since our compiler is using only the lower 64KB I assume it is safe to do so without overriding any program code.

I have a few questions however:

Thanks!

spirilis commented 7 years ago

For Wolverine (FRAM) usage, take a look at this- http://forum.43oh.com/topic/5474-energia-and-wolverine-tips/ - including my "HighMem" library which employs DMA to copy to/fro buffers within the lower-64KB space.

dazhbog commented 7 years ago

Thanks for the example. Looking at the HighMen lib i can see that this is very close to what I am looking for... but im stuck at actually implementing it :(

I struggle to pass the large unsigned long C pointer into a the generic registers r12-r15 and also how to return the data from assembly to C.

I can see many ways that it can be done, but i cant get any to work.. For example in this document (http://www.ti.com/lit/an/slaa376/slaa376.pdf) they show the intrinsic functions that I need, but i dont know how to encapsulate that with C, in Energia.

dazhbog commented 7 years ago

OK I think I might have solved it. Borrowing from the naming convention from the intrinsics I made the following 2 functions.

void __data20_write_char(unsigned long addr, unsigned char data)
{
  asm(" push   r15"::);           // push MSB part of addr argument
  asm(" push   r14"::);           // push LSB part of addr argument
  asm(" popx.a r15"::);           // load dat 20bit address
  asm(" movx.b r13, 0x0(r15)"::); // move the data argument to the location r15
  asm(" nop"::);                  // be useless for a bit
}

unsigned char __data20_read_char(unsigned long addr)
{
  asm(" push   r15"::);            // push MSB part of addr argument
  asm(" push   r14"::);            // push LSB part of addr argument
  asm(" popx.a r15"::);            // load dat 20bit address
  asm(" movx.b 0x0(R15), R12"::);  // move contents of the R15 location to R12
  asm(" push.w R12"::);            // not sure how to do this but here trying to move the result 
  asm(" pop.w  R15"::);            // back into r15 so that the char can be returned.
  asm(" nop"::);                   // if i remove this it doesnt work..
  asm(" ret"::);                   // return the contents of r15
}

I shall test more and report..

Closing for now.