View previous topic :: View next topic |
Author |
Message |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Thu Mar 21, 2013 1:00 pm |
|
|
Why this function is not working?
Code: | ...
#byte OPTION = 0b10011111
void main()
{
...
|
is not the same as the top function?
On compiler I do not have error's
thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 21, 2013 1:53 pm |
|
|
Read the CCS manual on the #byte statement. Read the PIC data sheet
on how to access the OPTION register for your PIC.
Don't expect us to do these things for you, when you could do it yourself.
The answers you want are in the CCS manual and PIC data sheet. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Thu Mar 21, 2013 1:56 pm |
|
|
#byte specifies a location, not a value (like you are trying to do). To access the option register on this chip, you cannot use #byte as it has no known location. You need to use the assembly command OPTION, so you need to look at the data sheet for examples on that. Then in the compiler manual help, look for #asm and #endasm for how to use those.
EDIT: PCM Programmer beat me to it! |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Thu Mar 21, 2013 11:19 pm |
|
|
jeremiah
Thank you for your information.
I understand now.
PCM programmer
Thanks, what I need your experience to understand some problems for me.
example of jeremiah is best for me.
Thank you guys.
Nailuy. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Fri Mar 22, 2013 3:32 am |
|
|
Lets make something clear here, you don't need to fiddle with assembler.
The option register on these chips, is accessed via the setup_wdt function in CCS.
The code to enable them if required, is simply:
Code: |
void main(void) {
setup_wdt(0);
}
|
which generates:
Code: |
0003: CLRF 07
0004: CLRF 01
0005: MOVLW 0F
0006: OPTION
0007: CLRWDT
0008: MOVF 07,W
0009: OPTION
|
Doing the required assembler to turn this on.
The reason there is not an 'option' to turn them on in CCS, is that the bit is negative logic, with a '1' turning this off. As soon as you program the timer/watchdog prescaler they are turned _on_ unless you add the option:
DISABLE_PULLUPS
The same applies for pin change from sleep.
As a further comment though, these are foul little chips. Why not get something like the PIC12F1501, which is cheaper now, especially in bulk, and has so many more resources. Makes life a lot easier....
Best Wishes |
|
|
|