nobner
- 30th January 2012, 22:59
Hello together,
i'm using the 12F1822 for the first time.
My programm does software-pwm, lighting 5 LED's up and down.
When i'm using 16MHz internal frequency (OSCCON = 01111000) everthing works fine.
When i'm using 32MHz internal frequency (OSCCON = 01110000) port RA4 and RA5 are working fine,
on ports RA0,1,2 i get short (200ns) high to low spikes in the high-time of my pwm-signal.
The spikes have a frequency of 50KHz.
I looked in the datasheet an tried to disable comparator, ADC, an so on.
Nothing helped.
Does anybody has an idea?
Thanks in advance!
Norbert
REM Prozessordefinitionen und Register setzen
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CLKOUTEN_OFF & _WDTE_ON & _PWRTE_OFF & _MCLRE_ON & _BOREN_ON
__config _CONFIG2, _PLLEN_ON
#ENDCONFIG
OSCCON = 110000
TRISA = 001000
ANSELA = 0
CM1CON0 = 0
disable
LED1 var PORTA.0
LED2 var PORTA.1
LED3 var PORTA.2
LED4 var PORTA.4
LED5 var PORTA.5
WERT_01 var byte
WERT_01 = 10
REM Wert auf 10 setzen, damit LED nicht ganz aus geht
WERT_02 var byte
WERT_02 = 10
REM Wert auf 10 setzen, damit LED nicht ganz aus geht
BASIS_01 VAR byte
BASIS_01 = 0
BASIS_02 VAR byte
BASIS_02 = 0
ZAEHL_101 var BYTE
ZAEHL_101=0
ZAEHL_102 var byte
ZAEHL_102=0
ZAEHL_201 var BYTE
ZAEHL_201=0
ZAEHL_202 var byte
ZAEHL_202=0
AUF_01 VAR BIT
AUF_01=0
AUF_02 VAR BIT
AUF_02=0
START:
rem LED1
IF AUF_01 = 0 THEN
IF WERT_01 < BASIS_01 then
led1=0
LED2=0
LED4=1
ENDIF
IF WERT_01 > BASIS_01 THEN
LED1=1
LED2=1
LED4=0
ENDIF
BASIS_01 = BASIS_01 + 1
IF BASIS_01 = 250 then LET BASIS_01 = 0
ZAEHL_101 = ZAEHL_101 + 1
IF ZAEHL_101 = 250 THEN
ZAEHL_102 = ZAEHL_102 + 1
ZAEHL_101 = 0
ENDIF
IF ZAEHL_102 = 5 THEN
WERT_01 = WERT_01 + 1
ZAEHL_102 = 0
ENDIF
IF WERT_01 = 240 AND BASIS_01 = 0 THEN
AUF_01 = 1
WERT_01 = 10
BASIS_01 = 10
ENDIF
endif
IF AUF_01 = 1 THEN
IF WERT_01 < BASIS_01 THEN
LED1=1
LED2=1
LED4=0
ENDIF
IF WERT_01 > BASIS_01 then
led1=0
LED2=0
LED4=1
ENDIF
BASIS_01 = BASIS_01 + 1
IF BASIS_01 = 250 then LET BASIS_01 = 0
ZAEHL_101 = ZAEHL_101 + 1
IF ZAEHL_101 = 250 THEN
ZAEHL_102 = ZAEHL_102 + 1
ZAEHL_101 = 0
ENDIF
IF ZAEHL_102 = 5 THEN
WERT_01 = WERT_01 + 1
ZAEHL_102 = 0
ENDIF
IF WERT_01 = 240 And basis_01 = 0 THEN
AUF_01 = 0
WERT_01 = 10
BASIS_01 = 10
ENDIF
REM Wert auf 240 und 10 setzen, damit LED nicht ganz aus geht
endif
REM LED2
IF AUF_02 = 0 THEN
IF WERT_02 < BASIS_02 then
led3=0
LED5=0
ENDIF
IF WERT_02 > BASIS_02 THEN
LED3=1
LED5=1
ENDIF
BASIS_02 = BASIS_02 + 1
IF BASIS_02 = 250 then LET BASIS_02 = 0
ZAEHL_201 = ZAEHL_201 + 1
IF ZAEHL_201 = 250 THEN
ZAEHL_202 = ZAEHL_202 + 1
ZAEHL_201 = 0
ENDIF
IF ZAEHL_202 = 3 THEN
WERT_02 = WERT_02 + 1
ZAEHL_202 = 0
ENDIF
IF WERT_02 = 240 AND BASIS_02 = 0 THEN
AUF_02 = 1
WERT_02 = 10
BASIS_02 = 10
ENDIF
endif
IF AUF_02 = 1 THEN
IF WERT_02 < BASIS_02 THEN
LED3=1
LED5=1
ENDIF
IF WERT_02 > BASIS_02 then
led3=0
LED5=0
ENDIF
BASIS_02 = BASIS_02 + 1
IF BASIS_02 = 250 then LET BASIS_02 = 0
ZAEHL_201 = ZAEHL_201 + 1
IF ZAEHL_201 = 250 THEN
ZAEHL_202 = ZAEHL_202 + 1
ZAEHL_201 = 0
ENDIF
IF ZAEHL_202 = 3 THEN
WERT_02 = WERT_02 + 1
ZAEHL_202 = 0
ENDIF
IF WERT_02 = 240 AND BASIS_02 = 0 THEN
AUF_02 = 0
WERT_02 = 10
BASIS_02 = 10
ENDIF
REM Wert auf 240 und 10 setzen, damit LED nicht ganz aus geht
endif
GOTO START
end
i'm using the 12F1822 for the first time.
My programm does software-pwm, lighting 5 LED's up and down.
When i'm using 16MHz internal frequency (OSCCON = 01111000) everthing works fine.
When i'm using 32MHz internal frequency (OSCCON = 01110000) port RA4 and RA5 are working fine,
on ports RA0,1,2 i get short (200ns) high to low spikes in the high-time of my pwm-signal.
The spikes have a frequency of 50KHz.
I looked in the datasheet an tried to disable comparator, ADC, an so on.
Nothing helped.
Does anybody has an idea?
Thanks in advance!
Norbert
REM Prozessordefinitionen und Register setzen
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _CLKOUTEN_OFF & _WDTE_ON & _PWRTE_OFF & _MCLRE_ON & _BOREN_ON
__config _CONFIG2, _PLLEN_ON
#ENDCONFIG
OSCCON = 110000
TRISA = 001000
ANSELA = 0
CM1CON0 = 0
disable
LED1 var PORTA.0
LED2 var PORTA.1
LED3 var PORTA.2
LED4 var PORTA.4
LED5 var PORTA.5
WERT_01 var byte
WERT_01 = 10
REM Wert auf 10 setzen, damit LED nicht ganz aus geht
WERT_02 var byte
WERT_02 = 10
REM Wert auf 10 setzen, damit LED nicht ganz aus geht
BASIS_01 VAR byte
BASIS_01 = 0
BASIS_02 VAR byte
BASIS_02 = 0
ZAEHL_101 var BYTE
ZAEHL_101=0
ZAEHL_102 var byte
ZAEHL_102=0
ZAEHL_201 var BYTE
ZAEHL_201=0
ZAEHL_202 var byte
ZAEHL_202=0
AUF_01 VAR BIT
AUF_01=0
AUF_02 VAR BIT
AUF_02=0
START:
rem LED1
IF AUF_01 = 0 THEN
IF WERT_01 < BASIS_01 then
led1=0
LED2=0
LED4=1
ENDIF
IF WERT_01 > BASIS_01 THEN
LED1=1
LED2=1
LED4=0
ENDIF
BASIS_01 = BASIS_01 + 1
IF BASIS_01 = 250 then LET BASIS_01 = 0
ZAEHL_101 = ZAEHL_101 + 1
IF ZAEHL_101 = 250 THEN
ZAEHL_102 = ZAEHL_102 + 1
ZAEHL_101 = 0
ENDIF
IF ZAEHL_102 = 5 THEN
WERT_01 = WERT_01 + 1
ZAEHL_102 = 0
ENDIF
IF WERT_01 = 240 AND BASIS_01 = 0 THEN
AUF_01 = 1
WERT_01 = 10
BASIS_01 = 10
ENDIF
endif
IF AUF_01 = 1 THEN
IF WERT_01 < BASIS_01 THEN
LED1=1
LED2=1
LED4=0
ENDIF
IF WERT_01 > BASIS_01 then
led1=0
LED2=0
LED4=1
ENDIF
BASIS_01 = BASIS_01 + 1
IF BASIS_01 = 250 then LET BASIS_01 = 0
ZAEHL_101 = ZAEHL_101 + 1
IF ZAEHL_101 = 250 THEN
ZAEHL_102 = ZAEHL_102 + 1
ZAEHL_101 = 0
ENDIF
IF ZAEHL_102 = 5 THEN
WERT_01 = WERT_01 + 1
ZAEHL_102 = 0
ENDIF
IF WERT_01 = 240 And basis_01 = 0 THEN
AUF_01 = 0
WERT_01 = 10
BASIS_01 = 10
ENDIF
REM Wert auf 240 und 10 setzen, damit LED nicht ganz aus geht
endif
REM LED2
IF AUF_02 = 0 THEN
IF WERT_02 < BASIS_02 then
led3=0
LED5=0
ENDIF
IF WERT_02 > BASIS_02 THEN
LED3=1
LED5=1
ENDIF
BASIS_02 = BASIS_02 + 1
IF BASIS_02 = 250 then LET BASIS_02 = 0
ZAEHL_201 = ZAEHL_201 + 1
IF ZAEHL_201 = 250 THEN
ZAEHL_202 = ZAEHL_202 + 1
ZAEHL_201 = 0
ENDIF
IF ZAEHL_202 = 3 THEN
WERT_02 = WERT_02 + 1
ZAEHL_202 = 0
ENDIF
IF WERT_02 = 240 AND BASIS_02 = 0 THEN
AUF_02 = 1
WERT_02 = 10
BASIS_02 = 10
ENDIF
endif
IF AUF_02 = 1 THEN
IF WERT_02 < BASIS_02 THEN
LED3=1
LED5=1
ENDIF
IF WERT_02 > BASIS_02 then
led3=0
LED5=0
ENDIF
BASIS_02 = BASIS_02 + 1
IF BASIS_02 = 250 then LET BASIS_02 = 0
ZAEHL_201 = ZAEHL_201 + 1
IF ZAEHL_201 = 250 THEN
ZAEHL_202 = ZAEHL_202 + 1
ZAEHL_201 = 0
ENDIF
IF ZAEHL_202 = 3 THEN
WERT_02 = WERT_02 + 1
ZAEHL_202 = 0
ENDIF
IF WERT_02 = 240 AND BASIS_02 = 0 THEN
AUF_02 = 0
WERT_02 = 10
BASIS_02 = 10
ENDIF
REM Wert auf 240 und 10 setzen, damit LED nicht ganz aus geht
endif
GOTO START
end