Quantcast
Channel: MEL PICBASIC Forum
Viewing all 4743 articles
Browse latest View live

Non standard, 160 char LCD text displays, SPLC780 controller, anyone?

$
0
0
Hello.

Most LCD displays based on Hitachi controller clones, have maximum 80 characters to display - the biggest one so far being 20 chars X 4 lines. However, I've found a bigger ones, for example, this one has 40 chars X 4 lines, which means 160 chars. https://item.taobao.com/item.htm?id=14796013100 It is based on SPLC780C compatible controller. Quick lookup on datasheet appears that it should be compatible with Hitachi controller, (but display pinout itself is different), therefore we can use it with PBP using standard LCDOUT routines. Any ideas on that?

(Personally I'd prefer 20 chars x 8 lines display, but can't find such one yet)


16F886 ADC weird problem.

$
0
0
Hello. I want to use ADC in 16F886 and using the following circuitry. PortA is connected to Vdd via 10K resistor, and to GND via 10K adjustable resistor.

But the problem is, that even if I set pot to maximum, at ADC pin I should have 2.5 volts, right? but I have 4.6. In fact, to pull it below 4.6, I need to set pot to 3k or less value. I've changed pot, resistor, double checked wiring - all appears to be fine. The code I'm using is shown below. What can be cause of this?

Code:

;----[16F886 Hardware Configuration]--------------------------------------------
#CONFIG
cfg1 = _INTRC_OSC_NOCLKOUT    ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
cfg1&= _WDT_ON                ; WDT enabled
cfg1&= _PWRTE_OFF            ; PWRT disabled
cfg1&= _MCLRE_OFF            ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD
cfg1&= _CP_OFF                ; Program memory code protection is disabled
cfg1&= _CPD_OFF              ; Data memory code protection is disabled
cfg1&= _BOR_OFF              ; BOR disabled
cfg1&= _IESO_ON              ; Internal/External Switchover mode is enabled
cfg1&= _FCMEN_ON              ; Fail-Safe Clock Monitor is enabled
cfg1&= _LVP_OFF              ; RB3 pin has digital I/O, HV on MCLR must be used for programming
cfg1&= _DEBUG_OFF            ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
  __CONFIG _CONFIG1, cfg1

cfg2 = _BOR40V                ; Brown-out Reset set to 4.0V
cfg2&= _WRT_OFF              ; Write protection off
  __CONFIG _CONFIG2, cfg2

#ENDCONFIG
'chip configs
include "modedefs.bas"
TRISA=%00000000  'SET A TO OUTPUT
TRISC=%11110000
TRISB=%00000000
ANSELH=%00000000  ' ADC OFF B
ADCON1=%10000000  'adc justify
OSCCON=%01110101  'SET FREQUENCY TO 8MHZ
WPUB=%00000000    'turn off Pullups
CM1CON0=0        'DISABLE COMPARATORS
CM2CON0=0        'SAME HERE

DEFINE OSC 8 
'adcin config
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

'lcd config
' Set LCD Data port
DEFINE LCD_DREG PORTC 
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 4 
' Set LCD Register Select port
DEFINE LCD_RSREG PORTB 
' Set LCD Register Select bit
DEFINE LCD_RSBIT 1 
' Set LCD Enable port
DEFINE LCD_EREG PORTB 
' Set LCD Enable bit 
DEFINE LCD_EBIT 0 
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4 
' Set number of lines on LCD 
DEFINE LCD_LINES 2 
' Set command delay time in us
DEFINE LCD_COMMANDUS 1500 
' Set data delay time in us
DEFINE LCD_DATAUS 44

'io config
cvladi var word
acho:
adcin 0,cvladi

lcdout $fe,2, #cvladi, "      "
pause 100
goto acho


QR Code encoder

$
0
0
Does anyone knows how to create a QRCode encoder (at least for QRCode Level 3), or how to translate the Arduino libraries to PBP from the following link?
https://github.com/ricmoo/QRCode/tree/master/src

It should be used with a PIC18F family.
The Arduino library is writed in C and it use pointers and array's pointers... and I'm lost.

Any clue?

Thank you.

Is it possible to make LCDOUT asynchronous?

$
0
0
There is tight main loop, which should not be interrupted. But there is also need to update 1602 LCD at specified moments of time. LCDOUT statement is very slow and nothing can be done while it is running. So is there a way to make it less time consuming? I've seen a lot of serial adapters for it, will they do the trick?

Component recomendations

$
0
0
Hi Guys,

In the past you guys have helped me source components for various projects, and I need your help again.

I'm looking for a power MOSFET that is rated at 400 - 500v DC, and has a logic level gate value do can be driven via an opto isolated 5v logic pulse from a microcontroller / arduino. Needs to be through hole package.

Most of the FETs in my hobby box are 50v DC or less.

Revisiting Timers & Time Stamps

$
0
0
Richard and other wise masters of PIC processors,
I have an application where I want to record elapsed time stamps (of any units whatsoever) that accompany sensor data packets and the requirement (for me) is to do this without using interrupts or any code processing to keep the “clock counter”.
The obvious solution to this is to utilise one of the 16 bit on-chip timers that accompany many PICs.
So, basing this project on the PIC18F27J53 (utilising the plentiful on-chip flash to store the data), I decided to utilise the available reference clock output (which can postscale the system clock up to 32678 times) and hardwire that pin to the clock pulse input pin of Timer 1 (T1CKI)
With a 4Mhz system clock, this can provide a 4000000 / 32768 = 122.0703Hz input to timer1 which can be further prescaled up x8 times in Timer1 if necessary (not using that though).

So, I’ve written a simple program to verify the timing which basically
1.Sets up everything
2.resets timer1’s 16bit counter to 0
3.executes a pause statement for 65000 ms
4.reads timer1’s counter into a 16bit variable
5.reports the number within the variable

So, after 65sec pause, I should be getting a theoretical count of 7934 in Timer1, but I’m reporting 7942 every time I run the test. That equates to a ~60ms discrepancy. Now, to my (albeit ignorant) thinking, there shouldn’t really be much discrepancy at all as both the counter and pause command use the same system clock for timing and the code capturing the count is simply:

TMR1H = 0
TMR1L = 0
Pause 65000
Timer1_Out.lowbyte = TMR1L
Timer1_Out.highbyte = TMR1H

Any ideas what would be causing the discrepancy?

Notes:
Timer1 Settings
T1CON.7,6 = 10 ‘Timer1 clock source is the T1OSC or T1CKI pin
T1CON.5,4 = 00 ‘1:1 prescaling
T1CON.3=0 ‘Turn off external crystal driver
T1CON.2=0 ‘Synchronize external clock input (tried both sync and not sync)
T1CON.1=0 ‘Enables register read/write of Timer1 in two 8-bit operations
T1CON.0=1 ‘Enables Timer1

T1GCON.7 = 0 ‘Timer1 gate enable = off

‘REFERENCE OSCILLATOR CONTROL
REFOCON.7 = 1 ‘Reference oscillator is enabled on REFO pin
REFOCON.4 = 0 ‘System clock (FOSC) is used as the base clock; the base clock reflects any clock switching of the device
REFOCON.3-0 = 1111 ‘= Base clock value divided by 32,768

And yes, this PIC does have RTC functionality, but I need subsecond resolution for the ET stamps

Thanks for any insight,

Troy

16F887 hersout doesn't work

$
0
0
Hello everybody,

can someone help me with this problem? Why is this code not working?

CLEAR

;-- 16F887 external OSC @ 20Mhz ------
DEFINE OSC 20
OSCCON = 0 'SET SYSTEM CLOCK SWITCH BIT

;----- Configuration bits ------------------------------------------------
#CONFIG
Line1 = _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_ON
Line2 = _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_ON & _HS_OSC

__CONFIG _CONFIG1, Line1 & Line2
__CONFIG _CONFIG2, _WRT_HALF & _BOR40V
#ENDCONFIG

DEFINE HSER_RCSTA 90h ' Enable Serial PORT
DEFINE HSER_TXSTA 24h ' Enable transmit
DEFINE HSER_SPBRG 129 ' set USART to 9600 baud (when BRGH=1)
DEFINE HSER_CLROERR 1 ' Enable automatic overrun error

ANSEL=0 ' A/D disabled for ANS0 to ANS7
ANSELH=0 ' A/D disabled for ANS8 to ANS13
CM1CON0 = 0 ' Disable comparators
CM2CON0 = 0 ' These default to disabled at POR, but just in case
CM2CON1 = 0
ADCON1 = 7
IOCB = 0
INTCON = 0



Start:

hserout ["hello", 10, 13]

Pause 1000

goto start
end

PWM calculated?, not table

$
0
0
I have seen several posts about PWM in order to make a one phase inverter, and most use a long values table calculated to get the sine wave, but what if it calculates the duty value each time?


I have a graph where can be seen some details, but I don't see the way to attach it. There I see I will have to compensate about 1/7 of cicle time due to the calculation time.
-----------------
counter=0
loop:
duty=sine[(counter/100)] ' to compesate decimal handle in above lines PWM
pin,duty,1 ´ PWM pin,duty,cycle at 11,718 Hz
counter=counter+ n ' 127 cicles n=1, n= 127/195= 0.65 -> 65
if counter= 19500 then counter=0
goto loop
-----------------
So, What do you think about it?
Thank you in advance for your answer
L.J.

PBC and PBP ?

$
0
0
Using Micro code software -- refresh my memory please -- the pbc is the compiled file? use the pbp to write code? but why when I open the pbc file it looks like the pbp? if it's compiled, shouldn't it be gibberish or not open? -- thanks.

Apa102/sk9822

$
0
0
I know I had some responses from some who have used these before but was having an issue with the first led in a string going on with white after powering up. It's always nice to confirm what I did is a true fix so ....

Before I had in the initialization code --
LOW SDA
LOW SCL both being held low before program starts and having the problem

Changed it to
HIGH SDA
LOW SDA and (seemingly)(hopefully) that has fixed it.

guessing these react to a low/high transition perhaps? anyway, like I say, always nice to confirm. --thanks

DT Interrupts not Working with PIC16F19197

$
0
0
Hi, I'm banging my head against the walls trying to figure this one out. I'm trying to implement this very simple DT interrupt to toggle a LED,

http://www.picbasic.co.uk/forum/show...7472#post17472

The problem is that the program never goes to the interrupt handler ToggleLED1. I can make a LED blink in the MAIN loop, but it won't go to the Int handler. This chip is pretty new, so I'm wandering if the DT_INTS-14.bas or ReEnterPBP.bas files need any changes. I have tried playing with the other registers related to TMR1 like T1CLK, but nothing works. Any help is greatly appreciated. Thanks. Robert

Code:

LED1  VAR  PORTB.1

INCLUDE "DT_INTS-14.bas"    ' Base Interrupt System
INCLUDE "ReEnterPBP.bas"    ' Include if using PBP interrupts

ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler  TMR1_INT,  _ToggleLED1,  PBP,  yes
    endm
    INT_CREATE              ; Creates the interrupt processor
ENDASM

T1CON = $31                ; Prescaler=8, TMR1ON
@ INT_ENABLE  TMR1_INT    ; enable Timer 1 interrupts

Main:
  PAUSE 1
GOTO Main

'---[TMR1 - interrupt handler]--------------------------------------------------
ToggleLED1:
    TOGGLE LED1
@ INT_RETURN

Only $29.99 for PCB Assembly

$
0
0
ALLPCB will regularly give special offers to express our gratitude for your continuing trust and business. Now we provide a special offer for PCB Assembly orders -- only $29.99!

Order right now or you may miss the promotion!

The standard materials used by ALLPCB are Shengyi, King board A-grade PCBs materials. And Taiyo Ink used in ALLPCB is usually only used for high-end PCBs. The production equipment in ALLPCB is Dongtai drilling machine, Xiechen text printing machine.

Only $29.99 for PCB Assembly

$
0
0
ALLPCB will regularly give special offers to express our gratitude for your continuing trust and business. Now we provide a special offer for PCB Assembly orders -- only $29.99!

Order right now or you may miss the promotion!

The standard materials used by ALLPCB are Shengyi, King board A-grade PCBs materials. And Taiyo Ink used in ALLPCB is usually only used for high-end PCBs. The production equipment in ALLPCB is Dongtai drilling machine, Xiechen text printing machine.

Hserin and string handling help.

$
0
0
I'm starting project on a pic18f4431 using hserin and 2400 baud. The data link works fine between PC and PIC but when I'm processing the str after I've received it I'm having a little trouble. I 'm sending a string ":P123456789" where ":" is my sync char and "p" will be a char I supply for sub jumps. The rest 123456789 will be separated to three variables. So var 1 = 123 var 2 = 456 var 3 = 789. Currently I have three for loops splitting the data, but if I run all three I only get 123 456 2691 and if I omit loop number 1 I get 0 456 789. It seams to be loop number one but I can't figure this out. I may be going at this the wrong way. So if anyone has a little better solution that would be great. Basically I want to send one string :P123456789 and my data I want is 123 456 789.

Code:

'---[DEFINES AND SETUP]------------------------------------------
DEFINE OSC 4          ' DEFINE OSCILATOR SPEED
DEFINE HSER_RCSTA 90h ' Set receive register to receiver enabled
DEFINE HSER_TXSTA 20h ' Set transmit register to transmitter enabled
DEFINE HSER_BAUD 2400 ' Set baud rate
DEFINE HSER_SPBRG 25  ' Set SPBRG directly (normally set by HSER_BAUD)
DEFINE  HSER_CLROERR 1' Auto clear over-run errors

'---[SERIAL LCD SETUP]----------------------------------------------------------
DEFINE CHAR_PACING 1000  ' CHARACTER SPEED
SERPIN VAR PORTE.0      ' SET SERIAL PIN TO VARIABLE
'---[CAPTURE COMPAIR MODUALS]---------------------------------------------------
CCP1CON = %00000000      'CAPTUR COMPAIR MODUALS DISABLED
CCP2CON = %00000000
'-------------------------------------------------------------------------------
'---[ANALOG CHANELS TO DIGITAL]-------------------------------------------------
ANSEL0 = %00000000      ' Set AN0 to analog, AN1-AN7 to digital
ANSEL1 = %00000000      ' Set AN8 to digital, see datasheet
ADCON0 = %00000000      'ANALOG OFF
'---[ Alias ]-------------------------------------------------------------------
BUZZER VAR PORTB.5
LCDBaud CON 16780 '2400 BUAD
'-------------------------------------------------------------------------------
'---[ DS1302 PINS ]-------------------------------------------------------------
'CE  Var PORTB.2
'SDA  Var PORTB.3
'SCL Var PORTB.4
SDA VAR PORTD.2
SCL VAR PORTD.3
addr VAR byte
cont CON %10100000

'---[UART SETUP]----------------------------------------------------------------

'-------------------------------------------------------------------------------

SEROUT2 SERPIN,LCDBAUD,[$1b, $2a, $80] 'TURN ON CONTRAST
PAUSE 250
SEROUT2 SERPIN,LCDBAUD,[$FE,$1,"STARTING"] 

'---[VARIABLES]----------------------------------------
 I VAR BYTE          'STANDARD LOOP 
 CharIn VAR byte(10)  'SERIAL PORT INPUT STRING
 PartIn1 var BYTE(3)
 LengthHigh1 var BYTE(3)
 LengthLow1 var BYTE(3)
 PartIn2 var word
 LengthHigh2 var word
 LengthLow2 var word
 CharOut var byte

'---[MAIN PROGRAM]------------------------------------------------

TRISD = %11111000
PORTD = %00000000

'-------------------------------------------------------------------------------

Main
CLEAR
 
HSERIN 5000,TimeOut,[WAIT(":"),STR CHARIN\10]
HSEROUT ["Rcvd string: ", STR CHARIN\10,13,10]

' I'm sending strign ":P123456789"  : is my sync up char and the first
'char in the string "P" will eventually tell my program what to look for
'in other subs.


IF charin(0) = "P" THEN    '<--- works fine jumps to this block

    FOR I = 1 TO 3                  '    first for loop
      charout = charin(i)            '
      partin1(i-1) = charout        '
                                    '
    NEXT I                          '
    ARRAYREAD PARTIN1,[DEC PARTIN2]  '


    FOR I = 4 TO 6                          '  second for loop
      charout = charin(i)                    '
      lengthhigh1(i-4) = charout            '
                                            '
    NEXT I                                  '
    ARRAYREAD lengthhigh1,[DEC lengthhigh2]  '


    FOR I = 7 TO 9                          '  third for loop
      charout = charin(i)                    '
      lengthlow1(i-7) = charout              '
                                            '
    NEXT I                                  '
    arrayread lengthlow1,[dec Lengthlow2]    '

    'display back to terminal

    SEROUT2 SERPIN,LCDBAUD,[$FE,$1,"P:",# PARTIN2,":",# Lengthhigh2,":",# lengthlow2]
    HSEROUT ["PARTS:",DEC PARTIN2," HIGH LENGTH:",DEC Lengthhigh2," LOW LENGTH:",DEC lengthlow2,13,10]

ENDIF

GOTO MAIN

TimeOut:
    HSEROUT ["NO DATA",13,10]
    GOTO Main

Helpful custom ribbon cable manufacturer!

$
0
0
Hello all,

Have a very good day to all. I need your help, please. I need cheap and reliable custom ribbon cable manufacturer. How do you find out this? Do you rely on google for any kind of information. However, I found something while surfing I would like to share https://www.wiringo.com/ribbon-cables.html But my question is did anyone try this manufacturer site yet?

Please let me know. Thank you!

Tiny Bootloader and PIC18F27K40

$
0
0
Hi all,

I've been trying to get the tiny bootloader to work on the PIC18F27K40 and I am so close but hit a wall because I'm fumbling in the dark when it comes to assembly and the flash writing mechanism. I'm hoping someone can help me here.

Stripped down version of the test program to flash an LED:
Code:


  #CONFIG
    CONFIG FEXTOSC = HS                ;HS (crystal oscillator) above 8 MHz; PFM set to high power
    CONFIG RSTOSC = EXTOSC            ;EXTOSC operating per FEXTOSC bits (device manufacturing default)
    CONFIG CLKOUTEN = OFF              ;CLKOUT function is disabled
    CONFIG CSWEN = ON                  ;Writing to NOSC and NDIV is allowed
    CONFIG FCMEN = OFF          ;Fail-Safe Clock Monitor disabled
    CONFIG MCLRE = INTMCLR            ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin fuction is MCLR
    CONFIG PWRTE = ON                  ;Power up timer enabled
    CONFIG LPBOREN = ON              ;ULPBOR enabled
    CONFIG BOREN = SBORDIS            ;Brown-out Reset enabled , SBOREN bit is ignored
    CONFIG BORV = VBOR_285            ;Brown-out Reset Voltage (VBOR) set to 2.85V
    CONFIG ZCD = OFF                  ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
    CONFIG PPS1WAY = ON                ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
    CONFIG STVREN = ON                ;Stack full/underflow will cause Reset
    CONFIG DEBUG = OFF                ;Background debugger disabled
    CONFIG XINST = OFF                ;Extended Instruction Set and Indexed Addressing Mode disabled
    CONFIG WDTCPS = WDTCPS_31          ;Divider ratio 1:65536; software control of WDTPS
    CONFIG WDTE = OFF                  ;WDT Disabled
    CONFIG WDTCWS = WDTCWS_7          ;window always open (100%); software control; keyed access not required
    CONFIG WDTCCS = LFINTOSC          ;WDT reference clock is the 31.0 kHz LFINTOSC
    CONFIG WRT0 = OFF            ;Block 0 (000800-003FFFh) not write-protected
    CONFIG WRT1 = OFF            ;Block 1 (004000-007FFFh) not write-protected
    CONFIG WRT2 = OFF            ;Block 2 (008000-00BFFFh) not write-protected
    CONFIG WRT3 = OFF            ;Block 3 (00C000-00FFFFh) not write-protected
    CONFIG WRT4 = OFF            ;Block 4 (010000-013FFFh) not write-protected
    CONFIG WRT5 = OFF            ;Block 5 (014000-017FFFh) not write-protected
    CONFIG WRT6 = OFF            ;Block 6 (018000-01BFFFh) not write-protected
    CONFIG WRT7 = OFF            ;Block 7 (01C000-01FFFFh) not write-protected
    CONFIG WRTC = OFF            ;Configuration registers (300000-30000Bh) not write-protected
    CONFIG WRTB = OFF            ;Boot Block (000000-0007FFh) not write-protected
    CONFIG WRTD = OFF            ;Data EEPROM not write-protected
    CONFIG SCANE = OFF          ;Scanner module is NOT available for use, SCANMD bit is ignored
    CONFIG LVP = OFF            ;HV on MCLR/VPP must be used for programming
    CONFIG CP = OFF              ;UserNVM code protection disabled
    CONFIG CPD = OFF            ;DataNVM code protection disabled
    CONFIG EBTR0 = OFF          ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR1 = OFF          ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR2 = OFF          ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
    CONFIG EBTR3 = OFF          ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
    CONFIG EBTR4 = OFF          ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR5 = OFF          ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR6 = OFF          ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
    CONFIG EBTR7 = OFF          ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
    CONFIG EBTRB = OFF          ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
  #ENDCONFIG

DEFINE OSC 16
DEFINE NO_CLRWDT 1      ' Don't waste cycles clearing WDT
@ ERRORLEVEL -306      ; turn off crossing page boundary message
CLEAR                  ' Set all registers to 0

PORTA = %00000000      ' Turn Off Port
TRISA = %00000000      ' Set PortA I/Os
WPUA = 0                ' PortA Weak Pull Ups disabled
ODCONA = 0              ' PortA Open Drain control. 1= sink, 0= src & sink
SLRCONA = 0            ' PortA Slew Rate control. 1= limited, 0= max rate
INLVLA = 0              ' PortA Input Level control. 1= ST, 0= TTL for IOC

PORTB = %00000000      ' Turn Off Port
TRISB = %11000001      ' Set PortB I/Os
WPUB = 0                ' PortB Weak Pull Ups disabled
ODCONB = 0              ' PortB Open Drain control. 1= sink, 0= src & sink
SLRCONB = 0            ' PortB Slew Rate control. 1= limited, 0= max rate
INLVLB = 0              ' PortB Input Level control. 1= ST, 0= TTL for IOC

PORTC = %00000000      ' Turn Off Port
TRISC = %10101000      ' Set PortC I/Os
WPUC = 0                ' PortC Weak Pull Ups disabled
ODCONC = 0              ' PortC Open Drain control. 1= sink, 0= src & sink
SLRCONC = 0            ' PortC Slew Rate control. 1= limited, 0= max rate
INLVLC = 0              ' PortC Input Level control. 1= ST, 0= TTL for IOC
 
ADCON0.0 = 0            ' ADC module turned Off
ANSELA = 0              ' PORTA A/D module disabled
ANSELB = 0              ' PORTB A/D module disabled
ANSELC = 0              ' PORTC A/D module disabled
CM1CON0.7 = 0                        ' Comparator #1 OFF
CM2CON0.7 = 0                        ' Comparator #2 OFF
CCP1CON.7 = 0          ' CCP1 module disabled
CCP2CON.7 = 0          ' CCP2 module disabled
CWG1CON0.7 = 0          ' CWG module disabled
DAC1CON0.7 = 0          ' DAC is disabled
FVRCON = 0              ' FVR and TIM modules disabled
ZCDCON.7 = 0            ' ZCD module disabled
PWM3CON.7 = 0          ' PWM3 is disabled
PWM4CON.7 = 0          ' PWM4 is disabled
SSP1CON1.5 = 0          ' MSSP module disabled
PIE0.4 = 1              ' IOC enabled
IOCEN.3 = 1            ' IOC on negative edge register enabled
IOCEP.3 = 1            ' IOC on positive edge register enabled

' See DS section 7.4 for definitions, "0" enables peripheral
PMD0 = %01111110        ' System Clock network and IOC module enabled
PMD1 = %11111110        ' TMR0 enabled
PMD2 = %11111111        '
PMD3 = %11111111        '
PMD4 = %00111111        ' Enable EUSART1 & 2. "0" enables peripheral
PMD5 = %11111111        '

' See DS section 17 for PPS I/O.
RX1PPS = $13            ' UART1 RX1 moved to RC3, DS 17.9.1
RX2PPS = $15            ' UART2 RX2 moved to RC5
RC2PPS = $09            ' RC2 selected for UART1 TX1, DS 17.2, $09 = EUSART1 (TX/CK)
RC4PPS = $0B            ' RC4 selected for UART2 TX2, $0B = EUSART1 (TX/CK)
PPSLOCK.0 = 1          ' PPS settings locked, no changes allowed

'========================================================================
'                        Variable PORT Definitions     
'========================================================================
Ser_RX_LED    VAR LATA.0    ' Serial RX LED indicator
Ser_TX_LED    VAR LATA.1    ' Serial TX LED indicator

Pwr_Save      VAR PORTB.0  ' STN2120 Power Save output for wake up signal
OBD_Sleep    VAR LATB.1    ' System Sleep control. 0= Sleep
Reset        VAR LATB.2    ' OBD2 Reset input. 0= Reset
Pwr_Dwn      VAR LATB.3    ' RS232 TX Power Down. 1= Enable
Ser_RX_EN    VAR LATB.4    ' RS232 RX Input enable. 0= Enable

RTS          VAR LATC.6    ' Serial RTS signal output
CTS          VAR PORTC.7  ' Serial CTS signal input

'========================================================================
'                        Variable Definitions     
'========================================================================
VARs:

Dummy      VAR BYTE        ' Used to clear RC2REG
Dest_add    VAR BYTE        ' Destination address to modem
Ser_RX1    VAR BYTE[15]    ' Serial RX1 data 15 bytes long
UART_RXa    VAR BYTE[44]    ' Serial RX2 data 1st set 44 bytes from STN2120
UART_RXb    VAR BYTE[44]    ' Serial RX2 data 2nd set 44 bytes from STN2120
UART_Val    VAR BYTE[8]    ' Converted ASCII to number value
UART_bytes  VAR BYTE        ' Number of bytes received from STN2120
Ser_TX1    VAR BYTE[14]    ' Serial TX data 14 bytes long
UART_TX    VAR BYTE        ' UART TX data variable for STN2120
Ser_Dat    VAR BYTE        ' Serial TX1 data variable for the SER1 TX routine
RX1_CKSM    VAR BYTE        ' Serial RX1 data checksum calculated variable
TX1_CKSM    VAR BYTE        ' Serial TX1 data checksum calculated variable
VIN        VAR BYTE[17]    ' VIN array variable
VIN_data    VAR BYTE[34]    ' VIN 2 byte ASCII value array holder
byte_loc    VAR BYTE        ' VIN Lookup variable
DataA      VAR BYTE        ' ASCII convert variable
DataB      VAR BYTE        ' ASCII convert variable
DataC      VAR BYTE        ' ASCII convert variable
DataD      VAR BYTE        ' ASCII convert variable

Thou        VAR WORD        ' ASCII convert variable
Hund        VAR WORD        ' ASCII convert variable
Tens        VAR BYTE        ' ASCII convert variable
sum        VAR BYTE        ' Calculation variable
a          VAR BYTE        ' RX1 interrupt loop counter
b          VAR BYTE        ' RX2 interrupt loop counter
c          VAR BYTE        ' UART_TX loop counter
d          VAR BYTE        ' UART_RX loop counter
e          VAR BYTE        ' Serial TX loop counter
f          VAR BYTE        ' ASCII loop counter
x          VAR BYTE        ' RX2 loop limit counter
Mode        VAR BYTE        ' Mode value sent to MG90
PID        VAR BYTE        ' PID value sent to MG90
STN        VAR BYTE        ' Memory read variable
Stat        VAR BYTE
' .0 = UART#1 RX started
' .1 = UART#1 RX completed
' .2 = UART#2 RX started
' .3 = UART#2 RX completed
' .4 = STN2120 routine selected
' .5 = TMR0 TOT
' .6 = Sleep mode (for current testing)

Store_B    VAR BYTE        ' PORTB IOC snapshot
Store_C    VAR BYTE        ' PORTC IOC snapshot

'//////////////////// Alias timer variables //////////////////////////////
TMR_0        VAR WORD        ' Timer0 preload variable

'=========================================================================

EUSARTs:
'=========================================================================
'                          EUSART #1
'=========================================================================

RC1STA = $90      ' Enable serial port & continuous receive
TX1STA = $20      ' Enable transmit, BRGH = 0
SP1BRGL = 51      ' 19200 Baud @ 16MHz, 0.16%
SP1BRGH = 0
BAUD1CON.3 = 1    ' Enable 16 bit baudrate generator

'=========================================================================
'                          EUSART #2
'=========================================================================

RC2STA = $90        ' Enable serial port & continuous receive
TX2STA = $20        ' Enable transmit, BRGH = 0
SP2BRGL = 51        ' 19200 Baud @ 16MHz, 0.16%
SP2BRGH = 0
BAUD2CON.3 = 1      ' Enable 16 bit baudrate generator

'=========================================================================
'                      Set values to variables     
'=========================================================================
Dest_add = $40    ' Default address but can be changed on the fly for testing
Ser_TX_LED = 0    ' Turn Off Serial output RJ45 RED LED
Ser_RX_LED = 0    ' Turn Off Serial output RJ45 GRN LED
Ser_RX_EN = 0    ' Enable Serial RX
Pwr_Dwn = 1      ' Enable Serial TX
OBD_Sleep = 1    ' Sleep mode disabled, 0 = Sleep enable
Reset = 1        ' OBD2 reset disabled, 0 = Reset enable
Stat = 0          ' Clear all status flags
CTS = 1          ' Set CTS signal OFF

PAUSE 100

Main:

  TOGGLE Ser_TX_LED
  PAUSE 100
 
GOTO Main

END

Here's my modified TinyBootloader.asm that assigns UART #1 to RC2 and RC3:
Code:

        radix DEC
        LIST  P=PIC18F27K40        ; change also: Configure->Select Device from MPLAB
xtal EQU 20000000                ; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
baud EQU 19200                        ; standard TinyBld baud rates: 115200 or 19200
        ; The above 3 lines can be changed and built a bootloader for the desired frequency (and PIC type)
       
        ;********************************************************************
        ;        Tiny Bootloader                18F series                Size=222words as of 9/2/2019
        ;        claudiu.chiculita@ugal.ro
        ;        http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
        ;       
        ;  Modified by LinkMTech to work with the PIC18F27K40 PPS directives
        ;  and EEPROM name changes.
        ;  icdpictypes.inc was also modified to include the PIC18F27K40
        ;********************************************************************

;        This source file is for PIC18F27K40

        #include "icdpictypes.inc"        ; Takes care of: #include "p18fxxx.inc",  max_flash, IdTypePIC
;        #include "bankswitch.inc"  ; Purpose? Half loads program with or without

                #define first_address max_flash-256                ;adjust to Bootloader size

        CONFIG FEXTOSC = HS                ;HS (crystal oscillator) above 8 MHz; PFM set to high power
        CONFIG RSTOSC = EXTOSC            ;EXTOSC operating per FEXTOSC bits (device manufacturing default)
        CONFIG CLKOUTEN = OFF              ;CLKOUT function is disabled
        CONFIG CSWEN = ON                  ;Writing to NOSC and NDIV is allowed
        CONFIG FCMEN = OFF          ;Fail-Safe Clock Monitor disabled
        CONFIG MCLRE = INTMCLR            ;If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin fuction is MCLR
        CONFIG PWRTE = ON                  ;Power up timer enabled
        CONFIG LPBOREN = ON              ;ULPBOR enabled
        CONFIG BOREN = SBORDIS            ;Brown-out Reset enabled, SBOREN bit is ignored
        CONFIG BORV = VBOR_285            ;Brown-out Reset Voltage (VBOR) set to 2.85V
        CONFIG ZCD = OFF                  ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
        CONFIG PPS1WAY = ON                ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
        CONFIG STVREN = ON                ;Stack full/underflow will cause Reset
        CONFIG DEBUG = OFF                ;Background debugger disabled
        CONFIG XINST = OFF                ;Extended Instruction Set and Indexed Addressing Mode disabled
        CONFIG WDTCPS = WDTCPS_31          ;Divider ratio 1:65536; software control of WDTPS
        CONFIG WDTE = OFF                  ;WDT Disabled
        CONFIG WDTCWS = WDTCWS_7          ;window always open (100); software control; keyed access not required
        CONFIG WDTCCS = LFINTOSC          ;WDT reference clock is the 31.0 kHz LFINTOSC
        CONFIG WRT0 = OFF            ;Block 0 (000800-003FFFh) not write-protected
        CONFIG WRT1 = OFF            ;Block 1 (004000-007FFFh) not write-protected
        CONFIG WRT2 = OFF            ;Block 2 (008000-00BFFFh) not write-protected
        CONFIG WRT3 = OFF            ;Block 3 (00C000-00FFFFh) not write-protected
        CONFIG WRT4 = OFF            ;Block 4 (010000-013FFFh) not write-protected
        CONFIG WRT5 = OFF            ;Block 5 (014000-017FFFh) not write-protected
        CONFIG WRT6 = OFF            ;Block 6 (018000-01BFFFh) not write-protected
        CONFIG WRT7 = OFF            ;Block 7 (01C000-01FFFFh) not write-protected
        CONFIG WRTC = OFF            ;Configuration registers (300000-30000Bh) not write-protected
        CONFIG WRTB = OFF            ;Boot Block (000000-0007FFh) not write-protected
        CONFIG WRTD = OFF            ;Data EEPROM not write-protected
        CONFIG SCANE = OFF          ;Scanner module is NOT available for use, SCANMD bit is ignored
        CONFIG LVP = OFF            ;HV on MCLR/VPP must be used for programming
        CONFIG CP = OFF              ;UserNVM code protection disabled
        CONFIG CPD = OFF            ;DataNVM code protection disabled   
        CONFIG EBTR0 = OFF          ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR1 = OFF          ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR2 = OFF          ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR3 = OFF          ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR4 = OFF          ;Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR5 = OFF          ;Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
        CONFIG EBTR6 = OFF          ;Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
        CONFIG EBTR7 = OFF          ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
        CONFIG EBTRB = OFF          ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks


;----------------------------- PROGRAM ---------------------------------
        cblock 0
        crc
        i
        cnt1
        cnt2
        cnt3       
        counter_hi
        counter_lo
        flag
        endc
        cblock 10
        buffer:64
        dummy4crc
        endc
       
SendL macro car
        movlw car
        movwf TX1REG  ; was TXREG
        endm
       
;0000000000000000000000000 RESET 00000000000000000000000000

                ORG    0x0000            ; was 0x0000. moved to Bank 1
                GOTO    IntrareBootloader

;view with TabSize=4
;&&&&&&&&&&&&&&&&&&&&&&&  START    &&&&&&&&&&&&&&&&&&&&&&
;----------------------  Bootloader  ----------------------
;PC_flash:                C1h                                U                H                L                x  ...  <64 bytes>  ...  crc       
;PC_eeprom:                C1h                                  40h  EEADR  EEDATA        0                crc                                       
;PC_cfg                          C1h                        U OR 80h        H                L                1                byte        crc
;PIC_response:          type `K`
       
        ORG first_address                ;space to deposit first 4 instr. of user prog.
        nop
        nop
        nop
        nop
        org first_address+8
       
IntrareBootloader
 
; Required to operate
        Banksel ANSELC
  movlw b'00000000'               
        movwf ANSELC                        ;Disable analog on Tx/Rx pins   
 
; UART1 RX1 moved to RC3
  Banksel RX1PPS    ; go to bank with RX1PPS registers
  movlw 0x13        ; load value of RC3
  movwf RX1PPS      ; to RX1PPS register
 
; RC2 selected for UART1 TX1 
  Banksel RC2PPS    ; go to bank with RC2PPS registers
  movlw 0x09        ; load value for TX1
  movwf RC2PPS      ; to RC2PPS register

                                                        ;Manually init serial port #1. Verified 19.23kb                                                       
; Modified UART1 values and names. Verified TX speed @ 19.2kb                                               
        movlw b'10010000'    ; Enable serial port & continuous receive = $90
        movwf RC1STA          ; Changed from RXSTA

        movlw b'00100000'    ; 5: Enable transmit, :2 BRGH = 0
        movwf TX1STA          ; Changed from TXSTA

        movlw b'00110011'      ;spbrgl_value = 51 
        movwf SP1BRGL          ; Changed from SPBRG
        movlw b'00000000'      ;spbrgh_value = 0
        movwf SP1BRGH          ; Changed from SPBRG       

        movlw b'00001000'      ;spbrg_value, 16-bit Baud rate generator used
        movwf BAUD1CON        ; Added BAUD1CON       

                                                        ;wait for computer
  rcall Receive                         
        sublw 0xC1                                    ;Expect C1h
        bnz way_to_exit
        SendL IdTypePIC                          ;send PIC type from "icdpictypes.inc", $C6
       
MainLoop
        SendL 'K'                                      ; "-Everything OK, ready and waiting."
mainl
        clrf crc
        rcall Receive                            ;Upper
        movwf TBLPTRU
                movwf flag                            ;(for EEPROM and CFG cases)               
        rcall Receive                            ;Hi
        movwf TBLPTRH
                movwf NVMADR              ;(for EEPROM case) * was EEADR               
        rcall Receive                            ;Lo
        movwf TBLPTRL
                movwf NVMDAT                    ;(for EEPROM case) * was EEDATA
        rcall Receive                            ;count
        movwf i
        incf i
        lfsr FSR0, (buffer-1)       
rcvoct                                                      ;read 64+1 bytes
                movwf TABLAT                    ;prepare for cfg; => store byte before crc
        rcall Receive
        movwf PREINC0
        decfsz i
        bra rcvoct       
        tstfsz crc                                    ;check crc
        bra ziieroare
                btfss flag,6                    ;is EEPROM data?
                bra noeeprom
                movlw b'00000100'          ;Setup eeprom
                rcall Write
                bra waitwre
noeeprom
                btfss flag,7                    ;is CFG data?
                bra noconfig
                tblwt*                                      ;write TABLAT(byte before crc) to TBLPTR***
                movlw b'11000100'          ;Setup cfg
                rcall Write
                bra waitwre
noconfig
                    ;write
eraseloop
        movlw        b'10010100'                  ; Setup erase
        rcall Write
        TBLRD*-                                              ; point to adr-1
       
writebigloop       
        movlw 8                                              ; 8groups
        movwf counter_hi
        lfsr FSR0,buffer
writesloop
        movlw 8                                              ; 8bytes = 4instr
        movwf counter_lo
writebyte
        movf POSTINC0,w                          ; put 1 byte
        movwf TABLAT
        tblwt+*
        decfsz counter_lo
        bra writebyte
       
        movlw        b'10000100'                  ; Setup writes
        rcall Write
        decfsz counter_hi
        bra writesloop
waitwre       
        ;btfsc NVMCON1,WR                ;for eeprom writes (wait to finish write)
        ;bra waitwre                          ;no need: round trip time with PC bigger than 4ms
       
        bcf NVMCON1,WREN                ; Clears WREN bit to disable writes
        bra MainLoop
       
ziieroare                                            ;CRC failed
        SendL 'N'
        bra mainl
         
;******** procedures ******************

Write ; See DS section11.1.2 for NVM Unlock Sequence instructions
;        BANKSEL NVMCON1        ; Bank to NVMCON1 register   
;  BSF    NVMCON1,WREN    ; Sets WREN bit to enable write/erase   
;  MOVLW  0x55            ; Load 55h   
;  MOVWF  NVMCON2        ; Step 1: Load 55h into NVMCON2   
;  MOVLW  0xAA            ; Step 2: Load W with AAh   
;  MOVWF  NVMCON2        ; Step 3: Load AAh into NVMCON2   
;  BSF    NVMCON1,WR      ; Step 4: Set WR bit to begin write/erase
;  NOP
;  RETURN

  movwf NVMCON1        ; Was movwf EECON1
        movlw 0x55
        movwf NVMCON2        ; Was EECON2
        movlw 0xAA
        movwf NVMCON2        ; Was EECON2
        bsf NVMCON1,WR                        ; WRITE       
        nop
        ;nop
        return

Receive       
  movlw xtal/1000000+1        ; for 20MHz => 11 => 1second delay                                                       
  movwf cnt1
rpt2                                               
        clrf cnt2
rpt3
        clrf cnt3               
rptc
  btfss PIR3,RC1IF                        ;test RX  (was PIR1,RCIF)               
  bra notrcv
    movf RC1REG,w                          ;return read data in W
    addwf crc,f                                  ;compute crc
  RETURN
               
notrcv
        decfsz cnt3
        bra rptc
        decfsz cnt2
        bra rpt3
        decfsz cnt1
        bra rpt2
       
;timeout:
way_to_exit; 
        bcf        RC1STA,        SPEN                        ; deactivate UART (was RCSTA)
        bra first_address

;*************************************************************
; After reset
; Do not expect the memory to be zero,
; Do not expect registers to be initialised like in catalog.

            END


The tinybldWin program shows a good "Flashwrite":
Code:

; tinyblWin log details capture

 
Trying to connect to: COM30
Com parameters: 8 N 0 False False
Connected to \\.\COM30 at 19200
  HEX: 3 min old, INHX32,18Fcode+cfg, total=284 bytes.
  Searching for PIC ...
Wait 350 ms
Rcv:type=C6h="Æ"
pic.BytesPerInstrPC=2  pic.BytesPerInstrPIC=2  pic.AddrIncrementPIC=2
StartBldZone=1FEF8  SizeOfBLDBytesPC=264
  Found:PIC18F27K40
  Reading HEX file...
Also found:
EEprom: __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
        __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Config: __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __


Prepare18FPre - Check HEX and GOTO
  Reallocate RESET to [1FEF8h..1FEFFh] (byte addr)
Prepare18FAfter - 0>Goto 1FF00,  Writing flash...
 Addr(bytes)=000000h,  4+128+1 bytes:
  Hex: 00 00 00 80 80 EF FF F0 05 6A 04 6E E8 6A 04 06 05 5A D8 A0 1A EF 00 F0
        03 0E 03 6E E6 0E 02 D8 F5 D7 03 6A FB 0F 02 6E 00 D0 E8 6A 01 D0 02 06
        03 5A FD E2 00 00 12 00 00 01 00 00 12 00 7D 0E E9 6E 0E 0E EA 6E ED 6A
        E9 50 EA 10 FC E1 EF 6A 8D 6A 88 6A 0F 01 10 6B 0F 6B 0E 6B 0D 6B 8E 6A
        C1 0E 89 6E 18 6B 17 6B 16 6B 15 6B 8F 6A A8 0E 8A 6E 20 6B 1F 6B 1E 6B
        1D 6B 60 90 11 6B 19 6B 21 6B 39 9F DC    Str:
      Sent count: 185
      wait for a byte max 500 ms
  Received "K": Ok

 Addr(bytes)=000080h,  4+128+1 bytes:
  Hex: 00 00 80 80 35 9F AC 9E A8 9E 44 9F 33 9F 31 6B 32 9F A5 9E A2 9E 96 9A
        0E 01 C2 89 0F 01 28 87 29 87 0E 01 7E 0E E1 6F FE 0E E2 6F E3 69 E4 69
        3F 0E E5 6F E6 69 13 0E B5 6F 15 0E 8D 6F 09 0E F9 6F 0B 0E FB 6F A0 81
        00 01 90 0E 9D 6E 20 0E 9E 6E 33 0E 9B 6E 9C 6A 9F 86 0E 01 90 0E 9D 6F
        20 0E 9E 6F 33 0E 9B 6F 9C 6B 9F 87 40 0E 29 6E 83 92 83 90 84 98 84 86
        84 82 84 84 31 6A 8F 8E 64 0E 00 01 75    Str:
      Sent count: 185
      wait for a byte max 500 ms
  Received "K": Ok

 Addr(bytes)=000100h,  4+128+1 bytes:
  Hex: 00 01 00 80 81 DF 83 72 7E 92 64 0E 7D DF FB D7 03 00 FE D7 FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF 12    Str:
      Sent count: 185
      wait for a byte max 500 ms
  Received "K": Ok

 Addr(bytes)=01FE80h,  4+128+1 bytes:
  Hex: 01 FE 80 80 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
        FF FF FF FF 1D EF 00 F0 05 6A 04 6E 9C    Str:þ€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿï
      Sent count: 185
      wait for a byte max 500 ms
  Received "K": Ok

 Flashwrite ok
  WRITE OK  at 9:42,  time:0.444 sec
Disconnecting...
OK

The problem is that the bootloader only writes every other 64 bytes of the program and leaves 64 bytes of blanks within the final load.
Here's the program memory read without bootloader:
Code:

0000- ef1d f000 6a05 6e04 6ae8 0604 5a05 a0d8
0010- ef1a f000 0e03 6e03 0ee6 d802 d7f5 6a03
0020- 0ffb 6e02 d000 6ae8 d001 0602 5a03 e2fd
0030- 0000 0012 0100 0000 0012 0e7d 6ee9 0e0e
0040- 6eea 6aed 50e9 10ea e1fc 6aef 6a8d 6a88
0050- 010f 6b10 6b0f 6b0e 6b0d 6a8e 0ec1 6e89
0060- 6b18 6b17 6b16 6b15 6a8f 0ea8 6e8a 6b20
0070- 6b1f 6b1e 6b1d 9060 6b11 6b19 6b21 9f39
0080- 9f35 9eac 9ea8 9f44 9f33 6b31 9f32 9ea5
0090- 9ea2 9a96 010e 89c2 010f 8728 8729 010e
00a0- 0e7e 6fe1 0efe 6fe2 69e3 69e4 0e3f 6fe5
00b0- 69e6 0e13 6fb5 0e15 6f8d 0e09 6ff9 0e0b
00c0- 6ffb 81a0 0100 0e90 6e9d 0e20 6e9e 0e33
00d0- 6e9b 6a9c 869f 010e 0e90 6f9d 0e20 6f9e
00e0- 0e33 6f9b 6b9c 879f 0e40 6e29 9283 9083
00f0- 9884 8684 8284 8484 6a31 8e8f 0e64 0100
0100- df81 7283 927e 0e64 df7d d7fb 0003 d7fe

Same program with tiny bootloader installed and writing the program:
Code:

0000- ef80 f0ff 6a05 6e04 6ae8 0604 5a05 a0d8
0010- ef1a f000 0e03 6e03 0ee6 d802 d7f5 6a03
0020- 0ffb 6e02 d000 6ae8 d001 0602 5a03 e2fd
0030- 0000 0012 0100 0000 0012 0e7d 6ee9 0e0e
0040- ffff ffff ffff ffff ffff ffff ffff ffff
0050- ffff ffff ffff ffff ffff ffff ffff ffff
0060- ffff ffff ffff ffff ffff ffff ffff ffff
0070- ffff ffff ffff ffff ffff ffff ffff ffff
0080- 9f35 9eac 9ea8 9f44 9f33 6b31 9f32 9ea5
0090- 9ea2 9a96 010e 89c2 010f 8728 8729 010e
00a0- 0e7e 6fe1 0efe 6fe2 69e3 69e4 0e3f 6fe5
00b0- 69e6 0e13 6fb5 0e15 6f8d 0e09 6ff9 0e0b
00c0- ffff ffff ffff ffff ffff ffff ffff ffff
00d0- ffff ffff ffff ffff ffff ffff ffff ffff
00e0- ffff ffff ffff ffff ffff ffff ffff ffff
00f0- ffff ffff ffff ffff ffff ffff ffff ffff
0100- df81 7283 927e 0e64 df7d d7fb 0003 d7fe
0110- ffff ffff ffff ffff ffff ffff ffff ffff
.
.
. I truncated file here of all ffff, too large
.
.
1fef0- ffff ffff ffff ffff ffff ffff ffff ffff
1ff00- 0000 0000 0000 0000 010f 0e00 6f21 010e
1ff10- 0e13 6fb5 010e 0e09 6ff9 0e90 6e9d 0e20
1ff20- 6e9e 0e33 6e9b 0e00 6e9c 0e08 6e9f d846
1ff30- 08c1 e153 0ec6 6e9a 0e4b 6e9a 6a00 d83e
1ff40- 6ef8 6e07 d83b 6ef7 6e7e d838 6ef6 6e80
1ff50- d835 6e01 2a01 ee00 f009 6ef5 d82f 6eec
1ff60- 2e01 d7fb 6600 d01f ac07 d003 0e04 d81e
1ff70- d018 ae07 d004 000c 0ec4 d818 d012 0e94
1ff80- d815 000a 0e08 6e05 ee00 f00a 0e08 6e06
1ff90- 50ee 6ef5 000f 2e06 d7fb 0e84 d807 2e05
1ffa0- d7f5 9481 d7c9 0e4e 6e9a d7c8 6e81 0e55
1ffb0- 6e82 0eaa 6e82 8281 0000 0012 0e15 6e02
1ffc0- 6a03 6a04 abcd d003 5099 2600 0012 2e04
1ffd0- d7f9 2e03 d7f6 2e02 d7f3 9e9d d791 ffff
1ffe0- ffff ffff ffff ffff ffff ffff ffff ffff
1fff0- ffff ffff ffff ffff ffff ffff ffff ffff

Since the PIC was not listed in the piccodes.ini file, I found the closest match ($C6) to work with and tried different combinations of value settings that would cause a failed write but never affected the way program gets loaded:
Code:

; "K" have different write page each;  flash:8,16,32,64,+
; Flash sizes Kwords: 4/8/16/32
;C0,C1: 4KW
;C2,C3: 8KW
$C2, K, 18K w/16KB F,      $4000, $100, 32, 32, 1, 3, 4, 0,
;                                      \EraseBlkI = 32words = 64B for small K
;                                          \ProgramBlk(Row)I = depends on PIC, can be 4/8/16/32words (8/16/32/64bytes)
;                                            ^  ^ make the product of those two be 32
;                            ^ from PDF ProgramMemoryMap
; those with write page larger than write page probably should have `erase_first` flag
;      PIC18F67K22:  send:128bytes  bld=2*64+4 instr (erase page the same as write page)
;
; Modified for 18F27K40, was: $C6, K, 18K w/128KB Flash, $20000, $100, 64, 64, 1, 8, 4, 0,
$C6, K, PIC18F27K40,  $20000, $400, 64,32,2, 2, 4, 0,

My circuit and final program work just fine and wanted to introduce the boot loader as the final feature but...
I have attached the serial portion of the schematic if it helps.
Attachment 8804

Sorry for the long post, just trying to be thorough...

Thanks
Attached Images

Unequal Timer0 count in interrupt mode.

$
0
0
Hi all! Please help me to fix the issue with unequal Timer0 count in interrupt mode. Please check the picture to see the gaps between pulses.

https://ibb.co/fnJkSks

The source code:

DEFINE LOADER_USED 1 'Define loader
DEFINE OSC 4 'Define oscillator

DEFINE HSER_RCSTA 90h 'Enable the receive register
DEFINE HSER_TXSTA 20h 'Enable the transmit register
DEFINE SER_BAUD 9600 'Set the baud rate
DEFINE HSER_BAUD 9600 'Set the baud rate

TRISB.3 = 0

INTCON = 100000 'Enable TMR0 interrupts
OPTION_REG = 000110 'Set prescaler 1:128
TMR0 = 175 'Load TMR0 register

ON INTERRUPT GOTO ISR

loop: 'Short code
PORTB.3 = 1 'Short code
GOTO loop 'Short code

DISABLE 'Disable interrupts
ISR: 'Entry point of the ISR
TMR0 = 175 'Load TMR0 register
HSEROUT [$F8] 'Send a byte
INTCON.2 = 0 'Reset INT0IF flag
RESUME 'Resume main program
ENABLE 'Enable interrupts

ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping

$
0
0
Note: ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping. Amicus Products

I'm dumping ALL surplus stock, Thousands of PIC micros, IC's , LCD's, surface mount components, Power supplies, test equipment, Development boards, Evaluation systems etc.

Its not commercially viable to list it all or even markdown all the prices on the Crownhill website, it simply takes too long. So if you browse the Crownhill Website and see anything in the hardware section or the components section, that interests you, PM me with an offer. Dont be shy.

Shipping for most packages will be £8.50, that is fully packed and tracked. If you fill your basket the MAXIMUM shipping you will pay, is £10.00.


Before the question is posed, I can say NO Crownhill is NOT closing, its business as usual. We are simply haveing the annual clear-out, but this year we are really going for it....we need the space. I never thought that with 10,00sqft we'd run out of space, but it seems we have. New business and projetcs that requre more space, demand that i either rent another building or empty this one. ...I'm not renting !!!

ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping

$
0
0
Note: ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping. Amicus Products

I'm dumping ALL surplus stock, Thousands of PIC micros, IC's , LCD's, surface mount components, Power supplies, test equipment, Development boards, Evaluation systems etc.

Its not commercially viable to list it all or even markdown all the prices on the Crownhill website, it simply takes too long. So if you browse the Crownhill Website and see anything in the hardware section or the components section, that interests you, PM me with an offer. Dont be shy.

Shipping for most packages will be £8.50, that is fully packed and tracked. If you fill your basket the MAXIMUM shipping you will pay, is £10.00.


Before the question is posed, I can say NO Crownhill is NOT closing, its business as usual. We are simply haveing the annual clear-out, but this year we are really going for it....we need the space. I never thought that with 10,00sqft we'd run out of space, but it seems we have. New business and projetcs that requre more space, demand that i either rent another building or empty this one. ...I'm not renting !!!

ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping

$
0
0
Note: ALL Amicus boards have been reduced to around £1.00 ex VAT and shipping. Amicus Products

I'm dumping ALL surplus stock, Thousands of PIC micros, IC's , LCD's, surface mount components, Power supplies, test equipment, Development boards, Evaluation systems etc.

Its not commercially viable to list it all or even markdown all the prices on the Crownhill website, it simply takes too long. So if you browse the Crownhill Website and see anything in the hardware section or the components section, that interests you, PM me with an offer. Don't be shy.

Shipping for most packages will be £8.50, that is fully packed and tracked. If you fill your basket the MAXIMUM shipping you will pay, is £10.00.


Before the question is posed, I can say NO Crownhill is NOT closing, its business as usual. We are simply having the annual clear-out, but this year we are really going for it....we need the space. I never thought that with 10,00sqft we'd run out of space, but it seems we have. New business and projects that require more space, demand that i either rent another building or empty this one. ...I'm not renting !!!
Viewing all 4743 articles
Browse latest View live