This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

24 bit address in 16 bit processor

Please do not say 'paging' I can not handle the overhead for all the other stuff that fit nicely within 64k.

I have a 2Mbyte flash that occasionally is accessed and the time here is not critical (the system pauses) as opposed to other processes that use only RAM.

Is there an elegant way to access structures in that 24 bit address space or does it have to be bent folded and mutilated to access?

Currently all addresses are specified with an 8 bit 'page' and a 16 bit 'address' and processed as such. I could gain some readability by having the whole in a long.

Also this method require data to be stored so no structure cross a page boundary and that limitation is a nuisance.

Erik

Parents Reply Children
  • I tried the AN160 suggestion, there is no difference. In the case of actually using a MX chip and CX51, this would be a gross error.

    C51  XMACtemq = (ReadPagedFlashC ((U32) (GPtsd + TSDflags), GC_TXI_pg) & OCU_TEXT_MASK);
    001E E500        E     MOV     A,GPtsd+01H
    0020 2401              ADD     A,#01H
    0022 FF                MOV     R7,A
    0023 E500        E     MOV     A,GPtsd
    0025 3400              ADDC    A,#00H
    0027 FE                MOV     R6,A
    0028 E4                CLR     A
    0029 FC                MOV     R4,A
    002A FD                MOV     R5,A
    002B AD00        E     MOV     R5,GC_TXI_pg
    002D 120000      E     LCALL   _ReadPagedFlashC
    
    C51  XMACtemq = (ReadPagedFlashC ((U16) (GPtsd + TSDflags), GC_TXI_pg) & OCU_TEXT_MASK);
    001E E500        E     MOV     A,GPtsd+01H
    0020 2401              ADD     A,#01H
    0022 FF                MOV     R7,A
    0023 E500        E     MOV     A,GPtsd
    0025 3400              ADDC    A,#00H
    0027 FE                MOV     R6,A
    0028 AD00        E     MOV     R5,GC_TXI_pg
    002A 120000      E     LCALL   _ReadPagedFlashC
    
    CX51  XMACtemq = (ReadPagedFlashC ((U16) (GPtsd + TSDflags), GC_TXI_pg) & OCU_TEXT_MASK);
    001E E500        E     MOV     A,GPtsd+01H
    0020 2401              ADD     A,#01H
    0022 FF                MOV     R7,A
    0023 E500        E     MOV     A,GPtsd
    0025 3400              ADDC    A,#00H
    0027 FE                MOV     R6,A
    0028 AD00        E     MOV     R5,GC_TXI_pg
    002A 120000      E     LCALL   _ReadPagedFlashC
    
    CX51  XMACtemq = (ReadPagedFlashC ((U32) (GPtsd + TSDflags), GC_TXI_pg) & OCU_TEXT_MASK);
    001E E500        E     MOV     A,GPtsd+01H
    0020 2401              ADD     A,#01H
    0022 FF                MOV     R7,A
    0023 E500        E     MOV     A,GPtsd
    0025 3400              ADDC    A,#00H
    0027 FE                MOV     R6,A
    0028 E4                CLR     A
    0029 FC                MOV     R4,A
    002A FD                MOV     R5,A
    002B AD00        E     MOV     R5,GC_TXI_pg
    002D 120000      E     LCALL   _ReadPagedFlashC
    

    Erik

  • Instead of:

    U32 address = &MyStruct.MyField;

    what about:

    U32 address = (U32)&MyStruct + offsetof(MyStruct, MyField)

  • fine, but when it is structure within array fo structures within a structure and so on it becomes very unreadable.

    Erik

    Anyhow, with CX51 it should work, bcause there you can address 8Mbyte linearily.