|
|
View previous topic :: View next topic |
Author |
Message |
pebbert9
Joined: 31 Dec 2010 Posts: 39
|
dsPic33 Bootloader |
Posted: Sat Jul 23, 2022 3:31 pm |
|
|
Hello,
I am trying to go through the pcd bootloader example but when I try to upload the bootload file with SIOW it just times out after the first line sent.
Does anyone see an obvious mistake?
I will use an EEPROM address to trigger programming but for now it's just hardcoded true.
Also, I'm using an RS485 USB adapter for uploading.
These are my settings for SIOW: COM port: 9600 8N1
Software Flow Control - Both, XON 0x11, XOFF 0x13
Does anything else need to be enabled in SIOW?
Then I go to File > Download Software and pick the compiled bootload hex file.
I do get the "Waiting for Download..." message in the terminal window so I know the bootloader is at least waiting for the program.
Bootloader File
Code: | // Bootloader
#define ROM_WRITE_CAN_MODIFY_CONFIG_BITS
#include <33CK32MP502.h>
#device ICSP=2
#device ADC=12
#FUSES NOWDT, WINDIS, WPOSTS=512, NOPROTECT, HS, OSCIO, CKSNOFSM, PLLWAIT, XTGAIN2, XTBST, NODEBUG, AIVT
#use delay(crystal=16M,clock=160M)
#pin_select U1RX = PIN_B9
#pin_select U1TX = PIN_B7
#use rs232( baud=9600, UART1, enable=PIN_B8, bits=8, parity=N, stop=1, errors)
#define _bootloader
//#define BOOTLOADER_MODE2X
#include <pcd_bootloader.h>
#include <loader_pcd.c>
#org APPLICATION_START
void application(void)
{
while(TRUE);
}
void main(void)
{
unsigned int8 boot_data = 0x88; // Force ON for now
if( boot_data == 0x88 )
{
delay_ms(140); // wait for PLL
printf("\r\nBootloader Version 1.0\r\n");
// Let the user know it is ready to accept a download
printf("\r\nWaiting for download...");
// Load the program
load_program();
}
application();
}
#int_default
void isr(void)
{
jump_to_isr(LOADER_END+5);
}
|
Bootload File:
Code: | // Bootload File
#include <33CK32MP502.h>
#device ICSP=2
#device ADC=12
#FUSES NOWDT, WINDIS, WPOSTS=512, NOPROTECT, HS, OSCIO, CKSNOFSM, PLLWAIT, XTGAIN2, XTBST, NODEBUG, AIVT
#use delay(crystal=16M,clock=160M)
#define LED_PIN PIN_B10
//This is a necessary include file. It reserves space so that the bootloader is not overwritten.
#include <pcd_bootloader.h>
void main() {
output_low(LED_PIN);
while(TRUE) {
output_toggle(LED_PIN);
delay_ms(500);
}
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Sun Jul 24, 2022 5:41 am |
|
|
First thing get rid of ROM_WRITE_CAN_MODIFY_CONFIG_BITS.
Problem with having this set, is that if the loaded code makes any change
that affects the clock rate, then the bootloader will stop working. Remember
the bootloader is coded with delays dependent of the selected clock rate.
This is one of these things if is better to never use.
On your program to upload, just have the clock rate, and #fuses NONE.
Now if you are using RS485, normally this is half duplex so then something
in the PIC needs to be controlling the buffer direction. Is you enable pin
wired to do this?. How are the buffers setup?. When the PIC is sending
the receive buffer needs to be disabled, and the RX line on the PIC needs
a bias resistor to pull it high. Otherwise the PIC will see what it sends, or
noise and this will cause disaster.
On your adapter at the PC end, disable the UART buffer. Some devices
will keep sending after a XOFF is received, to empty the buffer. Again
disaster. How are the RS485 buffer directions controlled here?. Remember
the buffer needs to be set to receive whenever it is not sending, otherwise
the XOFF cannot get through from the PIC. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|