Professional Documents
Culture Documents
--------------------------------------------------------------------------------
HPWM
Use the following PBP DEFINE statements to specify the output pins for HPWM.
Check the Microchip datasheet (Peripheral Pin Select PPS) for the pins allowed
on each CCP/PWM channel. The PPS peripheral will automatically be configured
for the specified output pin upon execution of HPWM. When used on non-PPS
devices, these defines will only control the Data Direction SFRs (TRIS).
These defines set PPS SFRs only once at program initialization. You may
change the PWM output pin at any point in your program code by modifying
the PPS SFRs. The HPWM command may be used without these DEFINEs if you
manually configure the PPS and TRIS SFRs.
NO DEFAULT PPS IS SET for CCP/PWM channels for the K42 families. If you
fail to include the appropriate DEFINEs from above to locate the CCP/PWM
output pins for a specific channel, the HPWM command will not function for
said channel.
ONLY INCLUDE DEFINEs FOR USED HPWM CHANNELS! If you include DEFINEs from
above for unused CCP/PWM channels, the ports/pins specified as CCP/PWM
outputs may not function as normal I/O until the PPS SRFs are cleared
in your program code.
--------------------------------------------------------------------------------
HSEROUT/HSEROUT2
Use the following PBP DEFINE statements to specify the output pins for HSEROUT
and HSEROUT2. Check the Microchip datasheet (Peripheral Pin Select PPS) for the
pins allowed on each EUSART. The PPS peripheral will automatically be configured
for the specified RX/TX pins only once after reset or power up. This allows the
PPS SFRs to be changed at runtime to relocate the RX/TX pins as needed. These
defines will have no effect when code is executed on devices without PPS.
The K42 devices don't offer an 8-bit baud rate generator. All BRG values
must use the 16-bit calculation found in the datasheet. In pursuit of clarity,
the previous HSERx_SPBRG and HSERx_SPBRGH defines have been replaced and
will have no effect on the K42 devices. Use the following defines to initilize
the BRG register pairs with a 16-bit value. This will overwrite values
derived from the HSERx_BAUD defines, so these defines are only useful in
special cases. If no defines are used to set baud rate, the default of
9600 baud will be used.
DEFINE HSER_U1BRG 103 ' example for 9600 baud, BRGS=0, Fosc=16MHz
DEFINE HSER2_U2BRG 103
Since the K42 devices have built-in parity modes, the parity-related
DEFINEs are not used by the HSER commands. They will have no effect when
defined. See the device datasheet for UART parity modes. Built-in parity
error flags and interrupts will function when using HSER commands.
The following DEFINEs have no effect when used with K42 devices:
DEFINE HSERx_EVEN
DEFINE HSERx_ODD
DEFINE HSERx_BITS
DEFINE HSERx_RCSTA
DEFINE HSERx_TXSTA
DEFINE HSERx_SPBRG
DEFINE HSERx_SPBRGH