PIC32 – конфигурирование контроллера

Views: 1184


Первоначальная настройка микроконтроллера сводится к настройке регистров конфигураций. В этих регистрах производиться основная настройка микроконтроллера, это как мы в основном будем микроконтроллер. сразу возникает вопрос где найти описание и как их настраивать. Первым делом необходимо обратиться к файлу PIC32ConfigSet.html который можно найти в папке C:\Program Files (x86)\Microchip\xc32\v1.32\docs (если компилятор Си установлен по умолчанию).


пример описания для микроконтроллера

Configuration-Bit Settings for PIC32MX795F512H

Usage:

#pragma config SETTING = VALUE  

SRS Select (FSRSSEL)
FSRSSEL = PRIORITY_0 SRS Priority 0
FSRSSEL = PRIORITY_1 SRS Priority 1
FSRSSEL = PRIORITY_2 SRS Priority 2
FSRSSEL = PRIORITY_3 SRS Priority 3
FSRSSEL = PRIORITY_4 SRS Priority 4
FSRSSEL = PRIORITY_5 SRS Priority 5
FSRSSEL = PRIORITY_6 SRS Priority 6
FSRSSEL = PRIORITY_7 SRS Priority 7

 

Ethernet RMII/MII Enable (FMIIEN) – Настройка Ethernet модуля
FMIIEN = OFF RMII Enabled
FMIIEN = ON MII Enabled

 

Ethernet I/O Pin Select (FETHIO) – Настройка портов вывода Ethernet модуля
FETHIO = OFF Alternate Ethernet I/O
FETHIO = ON Default Ethernet I/O

 

CAN I/O Pin Select (FCANIO) – Настройка портов вывода CAN модуля
FCANIO = OFF Alternate CAN I/O
FCANIO = ON Default CAN I/O

 

USB USID Selection (FUSBIDIO)
FUSBIDIO = OFF Controlled by Port Function
FUSBIDIO = ON Controlled by the USB Module

 

USB VBUS ON Selection (FVBUSONIO)
FVBUSONIO = OFF Controlled by Port Function
FVBUSONIO = ON Controlled by USB Module

 

PLL Input Divider (FPLLIDIV) настройка предварительного делителя тактовой частоты. В этом делители необходимо выбрать такой коэффициент деления, чтобы после него тактовая была пределах от 4 до 5 МГц. Рекомендую выбирать вариант 4 МГц. Например, внешний генератор 8 Мгц, нам надо выбрать делитель на 2 FPLLIDIV = DIV_2.
FPLLIDIV = DIV_1 1x Divider
FPLLIDIV = DIV_2 2x Divider
FPLLIDIV = DIV_3 3x Divider
FPLLIDIV = DIV_4 4x Divider
FPLLIDIV = DIV_5 5x Divider
FPLLIDIV = DIV_6 6x Divider
FPLLIDIV = DIV_10 10x Divider
FPLLIDIV = DIV_12 12x Divider

 

PLL Multiplier (FPLLMUL) Настройка умножителя частоты. Тут необходимо выбрать такой множитель, чтобы частота не превышала максимальную рабочую (для варианта когда необходима максимальная производительность). Но тут надо понимать чем выше рабочая частота тем выше потребление, поэтому необходимо выбирать компромисс. Если мы все таки выбираем максимальную производительность, то например, надо 4 МГц * 20 – и мы получаем 80 МГц FPLLMUL = MUL_20.
FPLLMUL = MUL_15 15x Multiplier
FPLLMUL = MUL_16 16x Multiplier
FPLLMUL = MUL_17 17x Multiplier
FPLLMUL = MUL_18 18x Multiplier
FPLLMUL = MUL_19 19x Multiplier
FPLLMUL = MUL_20 20x Multiplier
FPLLMUL = MUL_21 21x Multiplier
FPLLMUL = MUL_24 24x Multiplier

 

USB PLL Input Divider (UPLLIDIV) настройка тактовой частоты USB модуля.
UPLLIDIV = DIV_1 1x Divider
UPLLIDIV = DIV_2 2x Divider
UPLLIDIV = DIV_3 3x Divider
UPLLIDIV = DIV_4 4x Divider
UPLLIDIV = DIV_5 5x Divider
UPLLIDIV = DIV_6 6x Divider
UPLLIDIV = DIV_10 10x Divider
UPLLIDIV = DIV_12 12x Divider

 

USB PLL Enable (UPLLEN)
UPLLEN = ON Enabled
UPLLEN = OFF Disabled and Bypassed

 

System PLL Output Clock Divider (FPLLODIV)
FPLLODIV = DIV_1 PLL Divide by 1
FPLLODIV = DIV_2 PLL Divide by 2
FPLLODIV = DIV_4 PLL Divide by 4
FPLLODIV = DIV_8 PLL Divide by 8
FPLLODIV = DIV_16 PLL Divide by 16
FPLLODIV = DIV_32 PLL Divide by 32
FPLLODIV = DIV_64 PLL Divide by 64
FPLLODIV = DIV_256 PLL Divide by 256

 

Oscillator Selection Bits (FNOSC)
FNOSC = FRC Fast RC Osc (FRC)
FNOSC = FRCPLL Fast RC Osc with PLL
FNOSC = PRI Primary Osc (XT,HS,EC)
FNOSC = PRIPLL Primary Osc w/PLL (XT+,HS+,EC+PLL)
FNOSC = SOSC Low Power Secondary Osc (SOSC)
FNOSC = LPRC Low Power RC Osc (LPRC)
FNOSC = FRCDIV16 Fast RC Osc w/Div-by-16 (FRC/16)
FNOSC = FRCDIV Fast RC Osc w/Div-by-N (FRCDIV)

 

Secondary Oscillator Enable (FSOSCEN)
FSOSCEN = OFF Disabled
FSOSCEN = ON Enabled

 

Internal/External Switch Over (IESO)
IESO = OFF Disabled
IESO = ON Enabled

 

Primary Oscillator Configuration (POSCMOD)
POSCMOD = EC External clock mode
POSCMOD = XT XT osc mode
POSCMOD = HS HS osc mode
POSCMOD = OFF Primary osc disabled

CLKO Output Signal Active on the OSCO Pin (OSCIOFNC)

OSCIOFNC = OFF Disabled
OSCIOFNC = ON Enabled
Peripheral Clock Divisor (FPBDIV)
FPBDIV = DIV_1 Pb_Clk is Sys_Clk/1
FPBDIV = DIV_2 Pb_Clk is Sys_Clk/2
FPBDIV = DIV_4 Pb_Clk is Sys_Clk/4
FPBDIV = DIV_8 Pb_Clk is Sys_Clk/8
Clock Switching and Monitor Selection (FCKSM)
FCKSM = CSECME Clock Switch Enable, FSCM Enabled
FCKSM = CSECMD Clock Switch Enable, FSCM Disabled
FCKSM = CSDCMD Clock Switch Disable, FSCM Disabled
Watchdog Timer Postscaler (WDTPS)
WDTPS = PS1 1:1
WDTPS = PS2 1:2
WDTPS = PS4 1:4
WDTPS = PS8 1:8
WDTPS = PS16 1:16
WDTPS = PS32 1:32
WDTPS = PS64 1:64
WDTPS = PS128 1:128
WDTPS = PS256 1:256
WDTPS = PS512 1:512
WDTPS = PS1024 1:1024
WDTPS = PS2048 1:2048
WDTPS = PS4096 1:4096
WDTPS = PS8192 1:8192
WDTPS = PS16384 1:16384
WDTPS = PS32768 1:32768
WDTPS = PS65536 1:65536
WDTPS = PS131072 1:131072
WDTPS = PS262144 1:262144
WDTPS = PS524288 1:524288
WDTPS = PS1048576 1:1048576
 Watchdog Timer Enable (FWDTEN)
FWDTEN = OFF WDT Disabled (SWDTEN Bit Controls)
FWDTEN = ON WDT Enabled
Background Debugger Enable (DEBUG)
DEBUG = ON Debugger is enabled
DEBUG = OFF Debugger is disabled
ICE/ICD Comm Channel Select (ICESEL)
ICESEL = ICS_PGx1 ICE EMUC1/EMUD1 pins shared with PGC1/PGD1
ICESEL = ICS_PGx2 ICE EMUC2/EMUD2 pins shared with PGC2/PGD2
Program Flash Write Protect (PWP)
PWP = OFF Disable
PWP = PWP4K First 4K
PWP = PWP8K First 8K
PWP = PWP12K First 12K
PWP = PWP16K First 16K
PWP = PWP20K First 20K
PWP = PWP24K First 24K
PWP = PWP28K First 28K
PWP = PWP32K First 32K
PWP = PWP36K First 36K
PWP = PWP40K First 40K
PWP = PWP44K First 44K
PWP = PWP48K First 48K
PWP = PWP52K First 52K
PWP = PWP56K First 56K
PWP = PWP60K First 60K
PWP = PWP64K First 64K
PWP = PWP68K First 68K
PWP = PWP72K First 72K
PWP = PWP76K First 76K
PWP = PWP80K First 80K
PWP = PWP84K First 84K
PWP = PWP88K First 88K
PWP = PWP92K First 92K
PWP = PWP96K First 96K
PWP = PWP100K First 100K
PWP = PWP104K First 104K
PWP = PWP108K First 108K
PWP = PWP112K First 112K
PWP = PWP116K First 116K
PWP = PWP120K First 120K
PWP = PWP124K First 124K
PWP = PWP128K First 128K
PWP = PWP132K First 132K
PWP = PWP136K First 136K
PWP = PWP140K First 140K
PWP = PWP144K First 144K
PWP = PWP148K First 148K
PWP = PWP152K First 152K
PWP = PWP156K First 156K
PWP = PWP160K First 160K
PWP = PWP164K First 164K
PWP = PWP168K First 168K
PWP = PWP172K First 172K
PWP = PWP176K First 176K
PWP = PWP180K First 180K
PWP = PWP184K First 184K
PWP = PWP188K First 188K
PWP = PWP192K First 192K
PWP = PWP196K First 196K
PWP = PWP200K First 200K
PWP = PWP204K First 204K
PWP = PWP208K First 208K
PWP = PWP212K First 212K
PWP = PWP216K First 216K
PWP = PWP220K First 220K
PWP = PWP224K First 224K
PWP = PWP228K First 228K
PWP = PWP232K First 232K
PWP = PWP236K First 236K
PWP = PWP240K First 240K
PWP = PWP244K First 244K
PWP = PWP248K First 248K
PWP = PWP252K First 252K
PWP = PWP256K First 256K
PWP = PWP260K First 260K
PWP = PWP264K First 264K
PWP = PWP268K First 268K
PWP = PWP272K First 272K
PWP = PWP276K First 276K
PWP = PWP280K First 280K
PWP = PWP284K First 284K
PWP = PWP288K First 288K
PWP = PWP292K First 292K
PWP = PWP296K First 296K
PWP = PWP300K First 300K
PWP = PWP304K First 304K
PWP = PWP308K First 308K
PWP = PWP312K First 312K
PWP = PWP316K First 316K
PWP = PWP320K First 320K
PWP = PWP324K First 324K
PWP = PWP328K First 328K
PWP = PWP332K First 332K
PWP = PWP336K First 336K
PWP = PWP340K First 340K
PWP = PWP344K First 344K
PWP = PWP348K First 348K
PWP = PWP352K First 352K
PWP = PWP356K First 356K
PWP = PWP360K First 360K
PWP = PWP364K First 364K
PWP = PWP368K First 368K
PWP = PWP372K First 372K
PWP = PWP376K First 376K
PWP = PWP380K First 380K
PWP = PWP384K First 384K
PWP = PWP388K First 388K
PWP = PWP392K First 392K
PWP = PWP396K First 396K
PWP = PWP400K First 400K
PWP = PWP404K First 404K
PWP = PWP408K First 408K
PWP = PWP412K First 412K
PWP = PWP416K First 416K
PWP = PWP420K First 420K
PWP = PWP424K First 424K
PWP = PWP428K First 428K
PWP = PWP432K First 432K
PWP = PWP436K First 436K
PWP = PWP440K First 440K
PWP = PWP444K First 444K
PWP = PWP448K First 448K
PWP = PWP452K First 452K
PWP = PWP456K First 456K
PWP = PWP460K First 460K
PWP = PWP464K First 464K
PWP = PWP468K First 468K
PWP = PWP472K First 472K
PWP = PWP476K First 476K
PWP = PWP480K First 480K
PWP = PWP484K First 484K
PWP = PWP488K First 488K
PWP = PWP492K First 492K
PWP = PWP496K First 496K
PWP = PWP500K First 500K
PWP = PWP504K First 504K
PWP = PWP508K First 508K
PWP = PWP512K First 512K
Boot Flash Write Protect bit (BWP) защита области загрузчика от перезаписи.
BWP = ON Protection Enabled
BWP = OFF Protection Disabled
Code Protect (CP) защита кода программы от чтения через программатор.
CP = ON Protection Enabled
CP = OFF Protection Disabled

 


Поделись этим!