Most peripherals on the 16F1827 are the same as previous parts, but you will need to
spend some time going through the 1827 data sheet to find out which ones are the same,
and which ones have changed.
Definitely have a look at the APFCON0 & APFCON1 registers.
Also, check your PI14EEXT.BAS to make sure it has APFCON0 VAR BYTE EXT and not
APFCON VAR BYTE EXT.
There should also be these definitions in the PI14EEXT.BAS file;
Code:
MDCON VAR BYTE EXT
MDSRC VAR BYTE EXT
MDCARH VAR BYTE EXT
MDCARL VAR BYTE EXT
If these aren't in there, just add them.
Then you can do cool stuff like this with the new Data Signal Modulator...
.
Code:
'****************************************************************
'* Name : DSM.BAS *
'* Author : B. Reynolds *
'* Notice : Copyright (c) 2010 http://www.Rentron.com *
'* : All Rights Reserved *
'* Date : 2/5/2010 *
'* Version : 1.0 *
'* Notes : Using the 16F1827 Data Signal Modulator for IR *
'* : serial communications with onboard USART. *
'****************************************************************
' MODOUT, RB3, outputs whatever you send with HSEROUT as a 40kHz
' modulated data stream.
ASM
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _VCAPEN_OFF & _LVP_OFF & _STVREN_OFF
ENDASM
DEFINE OSC 8
DEFINE HSER_BAUD 2400
Duty VAR WORD
TRISB = 0
Init:
PR2 = 49 ' Set PWM for ~40kHz
CCP1CON = %00001100 ' Mode select = PWM
T2CON = %00000100 ' %00000100 = TMR2 ON 1:1 prescale
Duty = 100 ' Roughly 50% duty cycle
CCP1CON.4 = duty.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = duty.1 ' a 10-bit word
CCPR1L = DUTY >> 2
APFCON0 = 1 ' CCP1 PWM output on RB0
OSCCON = %01110000 ' 8MHz internal
ANSELA = 0 ' all digital. A/D disabled
ANSELB = 0
MDCON = %11100000 ' modulator, MODOUT pin, slew rate limiting enabled
' Note: set MDSRC.7 to eliminate the TX signal output on RB2/TX
MDSRC = %00001010 ' USART TX is modulation source, TX output still active
MDCARH = %00000000 ' carrier OFF during idle periods
MDCARL = %00000100 ' carrier ON only when sending data
Main:
HSEROUT [$55] ' sends USART data out modulated at 40kHz
PAUSE 50
GOTO Main
END
The output of your 40kHz IR module spits out serial data you send with HSEROUT.
Bookmarks