18F8722 ve CCP3 pwm çıkış sorunu

Başlatan Maxim, 27 Kasım 2013, 15:04:04

Maxim

18F8722 ile RGB led kontrolü yapmaya çalışıyorum

mavi rengin bağlı olduğu PORTG.0 ccp3 çıkışında sıkıntım var
HPWM ile sürmeye kalkınca yeşil led yanıyor!
(mavi çıkışı high veya low yapınca çalışıyor)

kırmızı ve yeşil çıkışlar düzgün çalışıyor

bir türlü çözemedim
problem proteus simulasyonunda da mevcut, gerçek devrede de.

led kontrolü için kullandığım basit proton+ kodu bu.


Device = 18F8722
Declare Xtal =10

Config_Start
  OSC = HS ;HS oscillator
  FCMEN = OFF ;Fail-Safe Clock Monitor disabled
  IESO = OFF ;Two-Speed Start-up disabled
  PWRT = On ;PWRT enabled
  BOREN = On ;Brown-out Reset enabled and controlled by software (SBOREN is enabled)
  BORV = 3 ;Minimum setting
  WDT = OFF ;WDT disabled (control is placed on the SWDTEN bit)
  WDTPS = 32768 ;1:32768
  MODE = MC ;Microcontroller mode
  ADDRBW = ADDR8BIT ;8-bit Address Bus
  DATABW = DATA8BIT ;8-bit External Bus mode
  Wait = OFF ;Wait selections are unavailable for table reads and table writes
  CCP2MX = PORTC ;ECCP2 input/output is multiplexed with RC1
  ECCPMX = PORTE ;ECCP1/3 (P1B/P1C/P3B/P3C) are multiplexed onto RE6, RE5, RE4 and RE3 respectively
  LPT1OSC = OFF ;Timer1 configured for higher power operation
  MCLRE = On ;MCLR pin enabled; RG5 input pin disabled
  STVREN = OFF ;Stack full/underflow will not cause Reset
  LVP = OFF ;Single-Supply ICSP disabled
  BBSIZ = BB2K ;1K word (2 Kbytes) Boot Block size
  XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  Debug = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
  Cp0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not code-protected
  CP1 = OFF ;Block 1 (004000-007FFFh) not code-protected
  CP2 = OFF ;Block 2 (008000-00BFFFh) not code-protected
  CP3 = OFF ;Block 3 (00C000-00FFFFh) not code-protected
  CP4 = OFF ;Block 4 (010000-013FFFh) not code-protected
  CP5 = OFF ;Block 5 (014000-017FFFh) not code-protected
  CP6 = OFF ;Block 6 (01BFFF-018000h) not code-protected
  CP7 = OFF ;Block 7 (01C000-01FFFFh) not code-protected
  CPB = OFF ;Boot Block (000000-0007FFh) not code-protected
  CPD = OFF ;Data EEPROM not code-protected
  WRT0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not write-protected
  WRT1 = OFF ;Block 1 (004000-007FFFh) not write-protected
  WRT2 = OFF ;Block 2 (008000-00BFFFh) not write-protected
  WRT3 = OFF ;Block 3 (00C000-00FFFFh) not write-protected
  WRT4 = OFF ;Block 4 (010000-013FFFh) not write-protected
  WRT5 = OFF ;Block 5 (014000-017FFFh) not write-protected
  WRT6 = OFF ;Block 6 (01BFFF-018000h) not write-protected
  WRT7 = OFF ;Block 7 (01C000-01FFFFh) not write-protected
  WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
  WRTB = OFF ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not write-protected
  WRTD = OFF ;Data EEPROM not write-protected
  EBTR0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not protected from table reads executed in other blocks
  EBTR1 = OFF ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
  EBTR2 = OFF ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
  EBTR3 = OFF ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
  EBTR4 = OFF ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
  EBTR5 = OFF ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
  EBTR6 = OFF ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
  EBTR7 = OFF ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
  EBTRB = OFF ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not protected from table reads executed in other blocks
Config_End


TRISA=%00000000
TRISB=%00000000
TRISC=%00000000
TRISD=%00000000
TRISE=%00000000
TRISF=%00000000
TRISG=%00000000
TRISH=%00000000
TRISJ=%00000000

Declare All_Digital = True

Declare CCP1_Pin = PORTC.2 'RED
Declare CCP2_Pin = PORTC.1 'GREEN
Declare CCP3_Pin = PORTG.0 'BLUE

Dim AAA As Byte

LOOP:

Inc AAA
DelayMS 10

'HPWM 1,255,2500 'RED
'HPWM 2,255,2500 'GREEN
HPWM 3,AAA,2500 'BLUE

GoTo LOOP



F®T

hocam simülasyon dosyasınıda yükleseydin.
"Hakk" şerleri hayr eyler Zannetme ki gayr eyler Ârif anı seyreyler Mevlâ görelim neyler Neylerse güzel eyler.

pwm.c

aynı kodları PBP'ya uyarlayarak ve ayrıca CCS ile de denedim. ikiside sorunsuz çalıştı.
sanırım proton kusuru olmalı.
_/\/\/\_ -[ı- -ı>|- -|ı|ı|ı- -ı< -||- -l[]l-

F®T

hocam Enhanced Capture 3 input/Compare 3 output/   bu pinde compare var bunu iptal ettinizmi?
"Hakk" şerleri hayr eyler Zannetme ki gayr eyler Ârif anı seyreyler Mevlâ görelim neyler Neylerse güzel eyler.

Maxim

#4
Alıntı yapılan: F.T - 27 Kasım 2013, 20:31:26
hocam Enhanced Capture 3 input/Compare 3 output/   bu pinde compare var bunu iptal ettinizmi?

dosyaları ekledim
o pinde compare mi var?
hemen bakayım

edit: yanlışın var PORTG.0 da comparator yok

F®T

Hocam pdf sayfa 30 da

Enhanced Capture 3 input/Compare 3 output/
PWM 3 output.
ECCP3 PWM output A.
"Hakk" şerleri hayr eyler Zannetme ki gayr eyler Ârif anı seyreyler Mevlâ görelim neyler Neylerse güzel eyler.

Maxim

compare - comparator karıştı
evet compare var doğru
şöyle bir deneme yaptım
CCP3CON=%00001100 yazıp denedim yani ccp3 ve diğerlerinide pwm moda set ettim gene aynı

F®T

#7
Hocam iş tamam.declare hpwm 3 olayı olmuyor.

istediğin gibi çalışıyor. ;)




Device = 18F8722
Declare Xtal =10

Config_Start
  OSC = HS ;HS oscillator
  FCMEN = OFF ;Fail-Safe Clock Monitor disabled
  IESO = OFF ;Two-Speed Start-up disabled
  PWRT = On ;PWRT enabled
  BOREN = On ;Brown-out Reset enabled and controlled by software (SBOREN is enabled)
  BORV = 3 ;Minimum setting
  WDT = OFF ;WDT disabled (control is placed on the SWDTEN bit)
  WDTPS = 32768 ;1:32768
  MODE = MC ;Microcontroller mode
  ADDRBW = ADDR8BIT ;8-bit Address Bus
  DATABW = DATA8BIT ;8-bit External Bus mode
  Wait = OFF ;Wait selections are unavailable for table reads and table writes
  CCP2MX = PORTC ;ECCP2 input/output is multiplexed with RC1
  ECCPMX = PORTE ;ECCP1/3 (P1B/P1C/P3B/P3C) are multiplexed onto RE6, RE5, RE4 and RE3 respectively
  LPT1OSC = OFF ;Timer1 configured for higher power operation
  MCLRE = On ;MCLR pin enabled; RG5 input pin disabled
  STVREN = OFF ;Stack full/underflow will not cause Reset
  LVP = OFF ;Single-Supply ICSP disabled
  BBSIZ = BB2K ;1K word (2 Kbytes) Boot Block size
  XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  Debug = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
  Cp0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not code-protected
  CP1 = OFF ;Block 1 (004000-007FFFh) not code-protected
  CP2 = OFF ;Block 2 (008000-00BFFFh) not code-protected
  CP3 = OFF ;Block 3 (00C000-00FFFFh) not code-protected
  CP4 = OFF ;Block 4 (010000-013FFFh) not code-protected
  CP5 = OFF ;Block 5 (014000-017FFFh) not code-protected
  CP6 = OFF ;Block 6 (01BFFF-018000h) not code-protected
  CP7 = OFF ;Block 7 (01C000-01FFFFh) not code-protected
  CPB = OFF ;Boot Block (000000-0007FFh) not code-protected
  CPD = OFF ;Data EEPROM not code-protected
  WRT0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not write-protected
  WRT1 = OFF ;Block 1 (004000-007FFFh) not write-protected
  WRT2 = OFF ;Block 2 (008000-00BFFFh) not write-protected
  WRT3 = OFF ;Block 3 (00C000-00FFFFh) not write-protected
  WRT4 = OFF ;Block 4 (010000-013FFFh) not write-protected
  WRT5 = OFF ;Block 5 (014000-017FFFh) not write-protected
  WRT6 = OFF ;Block 6 (01BFFF-018000h) not write-protected
  WRT7 = OFF ;Block 7 (01C000-01FFFFh) not write-protected
  WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
  WRTB = OFF ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not write-protected
  WRTD = OFF ;Data EEPROM not write-protected
  EBTR0 = OFF ;Block 0 (000800, 001000 or 002000-003FFFh) not protected from table reads executed in other blocks
  EBTR1 = OFF ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
  EBTR2 = OFF ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
  EBTR3 = OFF ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
  EBTR4 = OFF ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
  EBTR5 = OFF ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
  EBTR6 = OFF ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
  EBTR7 = OFF ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
  EBTRB = OFF ;Boot Block (000000-007FFF, 000FFF or 001FFFh) not protected from table reads executed in other blocks
 
Config_End


TRISA=%00000000
TRISB=%00000000
TRISC=%00000000
TRISD=%00000000
TRISE=%00000000
TRISF=%00000000
TRISG=%00000000
TRISH=%00000000
TRISJ=%00000000


Declare All_Digital = True

Declare CCP1_Pin = PORTC.1 'RED
Declare CCP2_Pin = PORTC.2 'GREEN
Declare CCP3_Pin = PORTG.0 'BLUE

Dim AAA As Byte


CCP3CON=%00001100    'ccp3 pwm moduna alınır

LOOP:

Inc AAA
If AAA=256 Then AAA=0
DelayMS 10

HPWM 1,AAA,2500 'RED
HPWM 2,AAA,2500 'GREEN
'HPWM 3,aaa,2500 'BLUE
CCPR3L=AAA             'ccp3 prescaller değeri atanır

GoTo LOOP
"Hakk" şerleri hayr eyler Zannetme ki gayr eyler Ârif anı seyreyler Mevlâ görelim neyler Neylerse güzel eyler.

Maxim

evet teşekkürler oldu böyle ama her çıkışa aynısını yapmak gerekti yoksa gene karışıyor yeşil ile mavi.
acaba bu bir bug mıdır? karar veremedim

mesela hpwm.inc yardımcı dosyası var protonun
onu kullandım denedim, o da düzgün çalıştı
tabi onun içinde bir sürü yardımcı tanımlama var



şöyle tam oluyor

Declare All_Digital = True                  

Declare CCP1_Pin = PORTC.2 'RED
Declare CCP2_Pin = PORTC.1 'GREEN
Declare CCP3_Pin = PORTG.0 'BLUE

CCP3CON=%00001100    'ccp3 pwm moduna alınır

Dim AAA As Byte
Dim BBB As Byte
Dim CCC As Byte

LOOP:

AAA= AAA + 1
BBB= BBB + 5
CCC= CCC + 10

HPWM 1,AAA,2500 'RED
HPWM 2,BBB,2500 'GREEN
HPWM 3,CCC,2500 'BLUE

CCPR1L=AAA
CCPR2L=BBB
CCPR3L=CCC  'ccp3 prescaller değeri atanır

DelayMS 10
GoTo LOOP

F®T

maxim hocam olduğuna sevindim.kolay gelsin.
"Hakk" şerleri hayr eyler Zannetme ki gayr eyler Ârif anı seyreyler Mevlâ görelim neyler Neylerse güzel eyler.

Powered by EzPortal