We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
As a part of an "In application programming" I am using the following assembler code:
#pragma asm MOV R0,#14 //OSC frec MOV R1,#02H //PROGRAM DATA BYTE #pragma endasm
I don't know if you can define SFRs below 0x80, however you could: unsigned char data *ptr=0; ptr[0]=0xa5; ptr[1]=0x5a; etc but be warned that this is highly dodgy as the compiler may well be using those registers. You would need to look carefully at the generated code. You would be much better sticking with assembler for this IAP stuff. What derivative are you using?
Hi Juan, How about the following c lines? It doesn't give exactly what you want, but it should be working. Pay attention to the order of two lines and the bank you are using. I will never do that in a real project. BTW, why do you hate #pragma? Sometimes you have to deal with it, like or not.
// If you are using bank 0 *((unsigned char data *) 0x01) = 2; // == MOV R1,#02H //PROGRAM DATA BYTE *((unsigned char data *) 0x00) = 14; // == MOV R0,#14 //OSC frec asm result in .src MOV R0,#01H MOV @R0,#02H MOV R0,#00H MOV @R0,#0EH
"I can't find the way of writing those two assembler lines in C" So don't do it, then! There's no point in struggling to write in 'C' just for the sake of it! This is definitely one of those areas where you're better off in assembler.
Thanks for you reply Stefan. Yes I think I will keep using assembler for IAP. About the derivative, I am using the P89C51RD2. I rather be using Atmel (AT89C51RD2) but it is out of stock in most of the distributors. The reason I prefer Atmel over Philips is that API calls are more flexible in Atmel. Again, thanks. Juan Baez
Hi Frank, Thanks for your reply, I have tried your lines but didn't work. I guest I will keep using assembler for IAP. Thanks Juan Baez