|
|
View previous topic :: View next topic |
Author |
Message |
just a guest Guest
|
ECCP and comparator problem |
Posted: Sun May 20, 2007 3:08 am |
|
|
Hi,
I want to use the shutdown of the ECCP module by the comparator. But It doesn't work. Here a simply democode:
Code: |
#include <16f883.h>
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
void main()
{
setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_L |
CCP_SHUTDOWN_ON_COMP1 | CCP_SHUTDOWN_AC_L |
CCP_SHUTDOWN_BD_H );
}
|
And the listing:
CCS PCM C Compiler, Version 4.033
...
.................... setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_L |
.................... CCP_SHUTDOWN_ON_COMP1 | CCP_SHUTDOWN_AC_L | CCP_SHUTDOWN_BD_H );
001C: BCF 03.5
001D: BCF 03.6
001E: BCF 07.2
001F: MOVLW 4D
0020: MOVWF 17
0021: BSF 03.5
0022: CLRF 1B
.................... }
0023: SLEEP
The Compiler should access the ECCPAS register (0x9c), but he doesn't initialise it. So the Shutdown doesn't work.
Any Ideas?
Thank you. |
|
|
Ttelmah Guest
|
|
Posted: Sun May 20, 2007 4:29 am |
|
|
I think the compiler is probably right!.
If you look at the data sheet, the special event triggers, are _only_available in 'compare mode', _not_ in 'PWM mode'. The idea is that an external input triggers the events. You are trying for a mode, that doesn't exist.
Best Wishes |
|
|
Guest
|
|
Posted: Sun May 20, 2007 6:04 am |
|
|
See the manual of the PIC16F833:
Quote: |
11.6.4 ENHANCED PWM AUTO-SHUTDOWN MODE
The PWM mode supports an Auto-Shutdown mode that
will disable the PWM outputs when an external
shutdown event occurs. Auto-Shutdown mode places
the PWM output pins into a predetermined state. This
mode is used to help prevent the PWM from damaging
the application.
The auto-shutdown sources are selected using the
ECCPAS<2> bits of the ECCPAS register. A shutdown
event may be generated by:
•A logic ‘0’ on the INT pin
• Comparator C1
• Comparator C2
• Setting the ECCPASE bit in firmware
...
|
Is there a specially trick to switch on this feature?
Best Regards |
|
|
Ttelmah Guest
|
|
Posted: Sun May 20, 2007 7:49 am |
|
|
OK. What puzzled me, is that in your posted code, you were trying to enable the CCP shutdown mode, which is specific to CCP operation, not PWM operation.
Which comparator mode do you want?.
I'd guess that the simplest way would just be to use a byte definition, and put the value you want into the register. The CCS versions for this sort of thing, are so damn complcated (with so many interactions), that for my money, they are more work than they are worth...
Remember you must program the comparator you want, to be 'off', before programming the EECPAS register. Writes are disabled that would trigger an immediate shutdown.
Remember you will need to either trigger a processor reset, or poll the status bit, to handle this.
As another comment, you are enabling 'fast_io', but have not programmed the TRIS registers anywhere.
Best Wishes |
|
|
Guest
|
|
Posted: Mon May 21, 2007 2:27 am |
|
|
Hi,
I declare the EECPAS in this way:
Code: |
#byte ECCPAS = 0x9C
// ...
ECCPAS = 0x31;
setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_L);
|
It works fine!
Thank you |
|
|
Ttelmah Guest
|
|
Posted: Mon May 21, 2007 4:27 am |
|
|
You see what I mean about the CCS functions!..
I must admit, I 'wish' that this stuff, was done much more as a set of defines, than as the 'hidden' functions. This way faults could be fixed much easier, and the whole compiler would become more flexible for new chips.
I have tended to do this myself as time has passed, using less and less of the CCS stuff, since it makes support much easier. I'd suggest adding a 'comment', saying what you are doing, or defining the 0x31 value, with a name to say what it does. It'll make future maintenance much easier.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|