Hi,
I'm programming a PIC 18LF4431 PIC using Oshonsoft.
I can't get PORTB to switch properly. I've tried the whole PORT and each of the individual PINS, but it seems dead. If I try PORTA all is well. The attached program works in the Oshonsoft Simulator, but not on the PCB. I can't see a problem with the PCB.
Any ideas please?
Camerart.
I'm programming a PIC 18LF4431 PIC using Oshonsoft.
I can't get PORTB to switch properly. I've tried the whole PORT and each of the individual PINS, but it seems dead. If I try PORTA all is well. The attached program works in the Oshonsoft Simulator, but not on the PCB. I can't see a problem with the PCB.
Any ideas please?
Camerart.
Code:
'18LF4431 SIMPLE SERVO TEST 180618 0800
Define CONFIG1H = 0x09 '0b00001001 /(ieso, fcmen disabled, intosc enabled, with clkout On RA6, And io On RA7)
Define CONFIG2L = 0x08 '0b00001000 /(vbor = 2.7v, boren disabled, pwrte enabled)
Define CONFIG2H = 0x00 '0b00000000 /(wdt window disabled, wdt disabled)
Define CONFIG3L = 0x00 '0b00000000 /(all configuration bits are unlikely To cause problems)
'Define CONFIG3H = 0x00 '0b00000000 /(set any pin swaps so they aren't using RCx; MCLR is disabled, and an input instead)
Define CONFIG3H = 0x80 'MCLR ENABLED
Define CONFIG4L = 0x80 '0b10000000 /(debug, lvp And stvren are disabled)
Define CONFIG5L = 0x0f '0b00001111 /(Disable code protection)
Define CONFIG5H = 0xc0 '0b11000000 /(Disable other code protection)
Define CONFIG6L = 0x0f '0b00001111 /(Disable Write protection)
Define CONFIG6H = 0xe0 '0b11100000 /(Disable other Write protection)
Define CONFIG7L = 0x0f '0b00001111 /(Disable table reads from other tables)
Define CONFIG7H = 0x40 '0b01000000 /(Disable table reads To boot block)
'Define SIMULATION_WAITMS_VALUE = 1 'Comment in for SIM out for PIC
Define CLOCK_FREQUENCY = 8
Define SINGLE_DECIMAL_PLACES = 2
Define STRING_MAX_LENGTH = 40 'Needs raising to fit the whole NMEA sentence for transmit>>>>>>>>>>
AllDigital
'SET PIN IN/OUT
TRISA = %00000000
TRISB = %00000000
TRISC = %10010000 '7=RX=1 4=SDI=1 1=RST=0
TRISD = %00010000 '7=RLED 4=BUTTON
TRISE = %00001001 '3=RESET 2=YLED
'SET BITS ON/OFF
PORTA = %00000000 'ON/OFF
PORTB = %00000000
PORTC = %00000000
PORTD = %00000000
PORTE = %00000000
ADCON0 = 0x03 'AN0-1-2-3 Can be used as Analogue inputs.
ADCON1 = 0x0e
ADCON2 = %10100100
PWMCON0 = %01000000 'PWM0-5 as PWM
PIR1 = 0
PIR2 = 0
PIE1 = 0
PIE2 = 0
PIE1.RCIE = 1 'rxd Intr , used for GPS serial input work
IPR1 = 0
IPR2 = 0
RCON.IPEN = 1 'this MUST be included when using Interrupts
OSCCON = %01110010 'internal 8Mhz clock
WaitMs 10
Dim msg1 As String 'any msg data will be passed via this string
Dim str1(44) As Byte '80 CCCCCCCCCCCCCC GPGGA STR1 ARRAY
Dim char As Byte
Dim rxi As Byte
Dim txi As Byte
Symbol yled = PORTD.7 'rled
Symbol wled = PORTE.2 'wled
Symbol button = PORTD.4
Symbol radset = PORTD.6
Disable High
Disable Low
msg1 = ""
Hseropen 9600
Hserout "Ready!", CrLf
wled = 1
WaitMs 1000
wled = 0
yled = 1
WaitMs 1000
yled = 0
Dim t As Byte
t = 60 'min 25
'PRESS BUTTON (OR RADSET)
radset = 0 'SET HC-12 COMMAND ON
WaitMs t
Hserout "AT+P8", CrLf '1= -1DB Lowest power- 8=20DB
WaitMs t
Hserout "AT+C001", CrLf '433.4
'Hserout "AT+C020", CrLf '441
WaitMs t
radset = 1 'SET HC-12 RUN ON
WaitMs 100
Hserout "MAIN", CrLf
OSCCON = %01110010 'internal 8Mhz clock
'Set up timer 0
T0CON = %10000111 '1:256
T0CON.TMR0ON = 1 'Bit7 = enables timer0
T0CON.T016BIT = 1 'Bit6 = timer0 is configured As an 8-Bit timer/TIME
T0CON.T0CS = 0 'Bit5 = Internal clock (FOSC/4)
T0CON.T0SE = 0 'Bit4 = 0 = Increment on low-to-high transition on T0CKI pin
T0CON.PSA = 0 'Bit3 = Timer0 prescaler is assigned.from prescaler output
T0CON.T0PS2 = 0 'Bit2 = 1:2 Prescale value
T0CON.T0PS1 = 0 'Bit1 = 1:2 Prescale value
T0CON.T0PS0 = 0 'Bit0 = 1:2 Prescale value
INTCON.TMR0IE = 1 'TMR0 BIT5 Overflow enable BIT
INTCON.TMR0IF = 0 'TMR0 BIT2 Overflow interrupt FLAG
INTCON.TMR0IF = 0 'added
loop:
PORTA = 255
yled = 1
WaitMs 1000
PORTA = 0
yled = 0
WaitMs 1000
PORTB = 255
wled = 1
WaitMs 1000
PORTB = 0
wled = 0
WaitMs 1000
Goto loop
Hserout "MAIN", CrLf
OSCCON = %01110010 'internal 8Mhz clock
'Set up timer 0
T0CON = %10000111 '1:256
T0CON.TMR0ON = 1 'Bit7 = enables timer0
T0CON.T016BIT = 1 'Bit6 = timer0 is configured As an 8-Bit timer/TIME
T0CON.T0CS = 0 'Bit5 = Internal clock (FOSC/4)
T0CON.T0SE = 0 'Bit4 = 0 = Increment on low-to-high transition on T0CKI pin
T0CON.PSA = 0 'Bit3 = Timer0 prescaler is assigned.from prescaler output
T0CON.T0PS2 = 0 'Bit2 = 1:2 Prescale value
T0CON.T0PS1 = 0 'Bit1 = 1:2 Prescale value
T0CON.T0PS0 = 0 'Bit0 = 1:2 Prescale value
INTCON.TMR0IE = 1 'TMR0 BIT5 Overflow enable BIT
INTCON.TMR0IF = 0 'TMR0 BIT2 Overflow interrupt FLAG
INTCON.TMR0IF = 0 'added
loop:
PORTA = 255
WaitMs 1000
PORTA = 0
WaitMs 1000
Goto loop
End
Attachments
-
4.3 KB Views: 1
Last edited by a moderator: