'182431 INT 8Mhz TIMER TEST 10.00 14.12.15
'This needs both sides of each H-Bridge pair connected together
Define SIMULATION_WAITMS_VALUE = 1
Define CONFIG1L = 0x00
Define CONFIG1H = 0x08
Define CONFIG2L = 0x0c
Define CONFIG2H = 0x20
Define CONFIG3L = 0x04
Define CONFIG3H = 0x80
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40
'PORTC.2 as CCP1 [pwm1] Forward
'PORTC,1 as CCP2 [pwm2] Reverse
'When running in Oshonsoft Sim
'to view PWM use Scope, Normal , Settings, display width 1000
'to check use Hardware UART
ADCON0 = %01000001
ADCON1 = %00000000
OSCCON = %01110010 'internal 8Mhz clock
Dim duty1 As Byte
Dim duty2 As Byte
Dim pwm1 As Byte
Dim pwm2 As Byte
Dim time As Byte
TRISA = %00000001
TRISB = %00000000
TRISC = %10001000
'assign PWM pins
PWMon 1, 8 'RC1 CCP1, Mode at 8MHz at 7812Hz, to change this look at the Manual Tables
PWMon 2, 8 'RC2 CCP2
duty1 = 100
duty2 = 155
'set up timer 1
T1CON.T1CKPS1 = 0 'bits 5 - 4 prescaler rate Select bits
T1CON.T1CKPS0 = 1 ' Bit 4
T1CON.T1OSCEN = 1 ' Bit 3 Timer1 Oscillator Enable Control Bit 1 = On
T1CON.T1SYNC = 1 ' Bit 2 Timer1 External Clock Input Synchronization Control Bit...1 = Do Not synchronize external clock Input
T1CON.TMR1CS = 0 ' Bit 1 Timer1 Clock Source Select Bit...0 = Internal clock (FOSC/4)
'testing only
main:
If RA0 = 1 Then
RB4 = 1
Else
RB4 = 0
Endif
Toggle RB6
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'wait for 10mS
TMR1H = 216
TMR1L = 242 ' Prescale for 10mS
T1CON.TMR1ON = 1
While
PIR1.TMR1IF
Wend
T1CON.TMR1ON = 0
time = time + 1
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
' carry on
If PORTA.3 = 0 Then
PWMduty 2, 0
'ASM: bcf CCP2CON,DC2B0
'ASM: bcf ccp2con,dc2b1
'ASM: movlw 0x00
'ASM: movwf ccpr2l
'Adcin 0, duty1>>>>>>>>>>>>>>>>>>>>>>>>>>>>.Not supported
PWMduty 1, duty1
Endif
If PORTA.3 = 1 Then
PWMduty 1, 0
'ASM: bcf CCP1CON,DC1B0
'ASM: bcf ccp1con,dc1b1
'ASM: movlw 0x00
'ASM: movwf ccpr1l
'Adcin 0, duty1>>>>>>>>>>>>>>>>>>>>>>>Not supported
PWMduty 2, duty1
Endif
Goto main