PDA

View Full Version : Micrtochip AN1310 for USART2



cerr99
- 27th May 2011, 18:21
Hi There,

I've been unlicky trying to modify Microchip's AN1310 bootloader to be used with USART2 instead of USART1. Did anyone suceed porting thatcode over to be used with USART2?
I have changed all the registers that referred to USART1 to USART2 I believe but still can't get it working.
Help would be appreciated!

Thank you very much!
Ron
Below is my preprocess.inc

; Copyright (c) 2002-2010, Microchip Technology Inc.
;
; Microchip licenses this software to you solely for use with Microchip
; products. The software is owned by Microchip and its licensors, and
; is protected under applicable copyright laws. All rights reserved.
;
; SOFTWARE IS PROVIDED "AS IS." MICROCHIP EXPRESSLY DISCLAIMS ANY
; WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT
; NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
; FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
; MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
; CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR
; EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY
; OR SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED
; TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
; OR OTHER SIMILAR COSTS.
;
; To the fullest extent allowed by law, Microchip and its licensors
; liability shall not exceed the amount of fees, if any, that you
; have paid directly to Microchip to use this software.
;
; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE
; OF THESE TERMS.

DigitalInput macro
#ifdef __18F1320
#if BOOTLOADER_ADDRESS == 0
nop ; start up GOTO instruction errata
#endif
bsf ADCON1, PCFG6 ; RB4/AN6/RX pin on PIC18F1x20 requires digital mode
#endif
#ifdef __18F1220
#if BOOTLOADER_ADDRESS == 0
nop ; start up GOTO instruction errata
#endif
bsf ADCON1, PCFG6 ; RB4/AN6/RX pin on PIC18F1x20 requires digital mode
#endif
endm

pmwtpi macro ; tblwt*+ macro for PIC18Fxx20 bug
#ifdef TBLWT_BUG
tblwt *
tblrd *+
#else
tblwt *+
#endif
endm

#ifndef BAUDRG
#ifndef USE_AUTOBAUD
#define USE_AUTOBAUD
#endif
#endif

#ifndef RXPORT
#ifdef PORTG
#define RXPORT PORTG
#else
#define RXPORT PORTB ; PIC18F1220, PIC18F1320
#endif
#endif

#ifndef RX
#ifdef PORTG
#define RX 2 ; most PIC18's have RX on RC7
#else
#define RX 4 ; PIC18F1220, PIC18F1320 have RX on RB4
#endif
#endif

#ifdef BRG16
#ifndef SPBRGH
#define SPBRGH SPBRGH2 ; PIC18F87J10 doesn't define SPBRGH by default.
#endif

#ifndef BAUDCON
#ifdef BAUDCON2
#define BAUDCON BAUDCON2 ; PIC18F85J90 / PIC18F84J90
#else
#ifdef BAUDCTL
#define BAUDCON BAUDCTL ; PIC18F1220, PIC18F1320
#endif
#endif
#endif
#endif

#ifndef RCREG
#ifdef RCREG2
#define RCREG RCREG2 ; PIC18F85J90/PIC18F84J90
#endif
#endif

#ifndef TXIF
#ifdef TX2IF
#define TXIF TX2IF ; PIC18F97J60 doesn't define TXIF by default
#endif
#endif

#ifndef RCIF
#ifdef RC1IF
#define RCIF RC2IF ; Not a problem on PIC18F97J60, but just in case future parts might need it
#endif
#endif

#if BOOTLOADERSIZE < ERASE_FLASH_BLOCKSIZE
; This device has a large Erase FLASH Block Size, so we need to reserve a full Erase Block
; page for the bootloader. Reserving an entire erase block prevents the PC application
; from trying to accidently erase a portion of the bootloader.
#define BOOTBLOCKSIZE ERASE_FLASH_BLOCKSIZE
#ifndef BOOTLOADER_ADDRESS
#ifdef CONFIG_AS_FLASH
#define BOOTLOADER_ADDRESS (END_FLASH - BOOTBLOCKSIZE - ERASE_FLASH_BLOCKSIZE)
#else
#define BOOTLOADER_ADDRESS (END_FLASH - BOOTBLOCKSIZE)
#endif
#endif
#else
#if (BOOTLOADERSIZE % ERASE_FLASH_BLOCKSIZE) == 0
#define BOOTBLOCKSIZE BOOTLOADERSIZE
#else
#define BOOTBLOCKSIZE (BOOTLOADERSIZE / ERASE_FLASH_BLOCKSIZE + 1) * ERASE_FLASH_BLOCKSIZE
#endif
#ifndef BOOTLOADER_ADDRESS
#define BOOTLOADER_ADDRESS (END_FLASH - BOOTBLOCKSIZE)
#endif
#endif

cerr99
- 27th May 2011, 18:59
Changed the DigitalInput macro in preprocess.inc to clean up with the analog input issues on my 18f86k22:

DigitalInput macro
#ifdef __18F86K22
#if BOOTLOADER_ADDRESS == 0
nop ; start up GOTO instruction errata
#endif
bcf ANCON2, ANSEL18
bcf ANCON2, ANSEL19
#endif
But that didn't get it going yet either... :(