Hi, If I have bad luck, MCON has change, when I remove the power supply. MCON: 0xc8 -> 0xcc, if it happent dyring a RTC access. And now I can't start my applikation before I have changed the MCON through the command line interface. I have tried to set the MCON register in the beginning of the program, through "Timed Access", but in vain! Can anyone tell me whats wrong with the code?
//DS5000T 32K TA = 0x0AA; // timed access TA = 0x55; MCON |= 0x02; // paa=1 TA = 0x0AA; // timed access TA = 0x55; MCON = 0xD8; // partition adr 6000h
I think your code should be:
#pragma disable void set_mcon (void) { TA = 0xAA; // timed access TA = 0x55; MCON |= 0x02; // paa=1 MCON = 0xD8; // partition adr 6000h TA = 0xAA; // timed access TA = 0x55; MCON &= ~0x02; // paa=0 }
Hi Jon! Thanks for your answer! It would work in a small memory model! But I'm using the large memory model. Here is the test sequence: 1.With the set_mcon(),placed right after the declaration of varibles in main(). 2.mcon = 0xcc 3.start the program -> program did't run(for long) and mcon = 0x08 now. I think I know the reason! The problem are that I can't run set_mcon(), before the declaration of varibles, and most of them are stored in xdata. That failes due to MCON = 0xCC(ece2=1). Is it possible run set_mcon() before any xdata access? thanks Pih Lung
Memory layout configuration doesn't belong into main(). Not into any C code at all, usually. Instead, you should do it by modifying startup.a51 accordingly.
Thanks Hans-Bernhard I could set ece2=0 from the startup.a51 /Pih Lung
Hi, I having the same problem as you i.e. setting the partition from sw application. You mentioned setting ece2=1 in startup.a51, hope you can explain how and where you set it ? Thanks
Hi dfg gdf! I put this code in the end of the startup.a51 file to set Mcon=88. PUSH PSW MOV TA,#0AAH MOV TA,#055H ORL MCON,#02H MOV MCON,#088H MOV TA,#0AAH MOV TA,#055H ANL MCON,#0FDH POP PSW MOV EA,C END Remember to set the right xdata start adr. in the beginning of the file. XDATASTART EQU 4000H Pih Lung
Hi, I copied the set of codes, but it didn't work well. a) Should I place the set of codes before or after "LJMP ?C_START" b) for "MOV EA, C", what is C, I gave it the value of #1. Is this correct ? c) In addition, I placed the following at the start of my codes MCON DATA 0C6H TA DATA 0C7H PSW DATA 0D0H d) Earlier, you mentioned "void set_mcon (void)", should this be invoked in the main() or commented out? Thanks.
hi a,b) right after LJMP ?C_START SETB C JBC EA,?C0158 CLR C ?C0158: PUSH PSW MOV TA,#0AAH MOV TA,#055H ORL MCON,#02H MOV MCON,#088H MOV TA,#0AAH MOV TA,#055H ANL MCON,#0FDH POP PSW MOV EA,C END c) my defines EA EQU 0xAF PSW EQU 0xD0 TA EQU 0xC7 MCON EQU 0xC6 d) commented out /Pih Lung
Hi, Thanks for your complete codes, but it still doesn't work. I debug and step-through. It seems that placing the MCON codes after LJMP ?C_START, will skip directly to main() without executing MCON codes. I tried to place it in other areas but no success. Am I missing something, for example should I configure additional parameters in the project options or should I use particular optimizations or memory model ? I am using small memomry model for Compact code rom size, optmization is 9, favour speed. Hope to hear from you. TIA
Hi My Project options: Device: use BL51 linker, not the LX51. Target: large, large, no OS. BL51 locate: code 0x0-0x3fff, xdata 0x4000-0x7fff code optim:6 or 8, but it has nothing to do with setting ECE2 in MCON, same thing with startup.a51 code. In the beginning of main() EA=0; MCON &= ~ECE2; EA=1; or set the original state of EA. This work for me! Pih Lung