View previous topic :: View next topic |
Author |
Message |
erothias Guest
|
How to alter CONFIG1L bits at runtime |
Posted: Wed Sep 14, 2005 3:58 pm |
|
|
Hi to everyone,
I want to change the oscillator settings at runtime, but i couldn't find a way to alter the bits of CONFIG1L and CONFIG1H. Write_program_eeprom cant do this, but read_progra_eeprom can display their contents. Does anyone know a solution to my problem.
PS: I can accept asm codes as well.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 14, 2005 4:07 pm |
|
|
For what PIC ? |
|
|
erothias Guest
|
|
Posted: Wed Sep 14, 2005 4:26 pm |
|
|
Sorry, i forgot
It is 18F4550
CCS compiler version: 3.227 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 14, 2005 5:01 pm |
|
|
The EECON1 register has a bit, CFGS, which has to be set = 1 to
access the Configuration memory. CFGS is bit 6 in EECON1.
I compiled a test program, using the address of the Config1 register
and you can see that CCS is clearing the CFGS bit. CCS is not
checking the address to see if it's in the range of the Config bits.
To fix this I think you have to write your own routine to write to
the config memory.
A better question to ask would be, do you really need to do this ?
The 18F4550 has many oscillator options. Maybe some other
method would solve your problem ?
Code: |
..... write_program_memory(0x300000, &config1, 2);
0054: BSF FD0.6
0056: BCF FA6.6 // CFGS bit is set = 0
0058: MOVLW 30
005A: MOVWF FF8
005C: CLRF FF7
005E: CLRF FF6 |
|
|
|
|