 |
 |
View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19828
|
|
Posted: Wed Mar 30, 2016 1:10 am |
|
|
Start at the beginning.
Are you intending to use USB?. If not, why are you using a 2550?.
If you are intending to use USB, you do realise that you cannot use this with the internal oscillator on this chip?. If you are intending to use USB, then you must get the crystal version working.
Now, step on. The C6/C7 code uses the hardware UART (hurrah). The original code you were using, was trying to use a software UART. The standard bootloader, does really need to be using the hardware UART. First thing to do, is to ignore the bootloader, and start with the following sequence:
1) The flash an LED test code. You say you have done this. Does it flash at the right speed?. This is vital before moving forwards.
The 2550, is a complex chip to get the oscillator working right. I'd always be explicit on the clock dividers. So:
Code: |
#include <18F2550.h>
#fuses NOWDT, CPUDIV1, HS, PLL5, VREGEN, NOXINST, NOPBADEN
#fuses STVREN, NOLVP, PUT
#use delay(clock=20MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
|
To work with a 20Mhz crystal, with the CPU at 20MHz, and be able to use USB
Or for the internal oscillator (no USB)
Code: |
#include <18F2550.h>
#fuses NOWDT, INTRC_IO, NOXINST, NOPBADEN, STVREN, NOLVP
#fuses NOVREGEN
#use delay(internal=8MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
|
Have you got MCLR pulled up?. If not, then NOMCLR needs to be added to the fuses in both cases.
Once you have got the LED flashing at the correct rate, move on to 2.
2) Then you need to test the RS232. So 'Hello World' output from a program, then once this is displaying properly move on to 3.
3) Test the other way. A simple program that looks for a character on the RS232, and replies. Only once this is working, move on.
4) Test the input you intend to use to trigger the bootloader.
Simple program to send a different message when this is seen high/low. Does this work?. If so, now move on to the bootloader.
5) The bootloader _requires_ XON/XOFF handshaking is enabled in the program you use to talk to it. Have you got this selected?. Personally I have had problems sometimes with this, unless it is set up in both the UART properties, and in the program itself.
6) Change your application. This is one where later compilers allow you to do something that older ones didn't, but the examples have never changed.
Alter the setup to:
Code: |
#include <18F2550.h>
#fuses NONE
#use delay(clock=8000000) //or 20Mhz if using the crystal version
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define LED_PIN PIN_B7
|
This ensures the code does not try to change the fuses (hurrah).... |
|
 |
robertom
Joined: 15 Mar 2016 Posts: 12
|
|
Posted: Thu Mar 31, 2016 7:24 pm |
|
|
Hi thanks for your comments,
I'm using the r232 example with a ftdi
1) i compile a led project with 1Hz and seems to work well
2) i made the test with the ftdi and tera term terminal and i receive the string
3) i made the project with the identification of the char and turning a led
Code: | void main(void) {
delay_ms(100);
output_high(LED1);
delay_ms(100);
int i = 0;
while(true){
delay_ms(1);
printf("Test %u\r\n",i++);
output_toggle(LED2);
output_toggle(LED1);
delay_ms(500);
output_toggle(LED2);
output_toggle(LED1);
delay_ms(500);
}
} |
4) I test the bootloader pin, when it starts it shows a text and when I restart it with the pin low it shows another message. I also turn on an led in the loader.c file to see if it is entering the loop when its buffering and seems to work well. Also i check the Rx and Tx on an oscilloscope to see the xon/xoff values and seems to be responding, not sure of the sync though.
5) The loader.c file has this
Code: | #define ACKLOD 0x06
#define XON 0x11
#define XOFF 0x13 |
on the siow terminal has the same values XON/XOFF, not sure of the ACKLOD on the siow terminal its not specified.
On tera term terminal i select the XON/XOFF mode i suppose it has the same values.
6)
I tried these fuses and config
Code: | #include <18F2550.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#fuses PLL1 //No PLL PreScaler
#fuses NOUSBDIV //USB clock source comes from primary oscillator
#fuses INTRC //Internal RC Osc
#fuses HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#fuses NOPUT //No Power Up Timer
//#fuses NOMCLR //Master Clear pin used for I/O
#fuses MCLR //Master Clear pin enabled
#fuses NOSTVREN //Stack full/underflow will not cause reset
#fuses NOWRTB //Boot block not write protected
#fuses NOWRTD //Data EEPROM not write protected
#fuses NOWRTC //Configuration registers not write protected
#fuses NOWRT //Program memory not write protected
#fuses NOEBTR //Memory not protected from table reads
#fuses NOEBTRB //Boot block not protected from table reads
#use delay(internal=8MHz)
#use FIXED_IO( A_outputs=PIN_A1,PIN_A0 )
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PC,ERRORS)
#define PUSH_BUTTON PIN_A1
#define LED1 PIN_C0
#define LED2 PIN_C1 |
The program seems to load right, even the pic restarts because i see the init text when its done but the program doesn't seem to load.
I added some fuses to leave exposed the write on the eeprom and tables to see if it helps.
on siow i paste the hex code but the pic seems to respond but when it finish it doesnt restart the pic or load the new program
on tera term, the program seems to load and it reset the pic but it runs the same program not the new one |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19828
|
|
Posted: Fri Apr 01, 2016 4:33 am |
|
|
I would try setting the handshake in device manager for the port, as well as in TeraTerm.
I have found a number of machines (and possibly may be TeraTerm version related), where the TeraTerm setting does not appear to correctly enable the XON/XOFF handshake. Remember you will see XOFF. This comes from the bootloader. The question is whether the PC stops sending when this is sent. If it doesn't, the next line of data, will be corrupted, checksum won't match, and it won't be written.
Try another package to send the data. CCS's 'ccsbotloader' for example. |
|
 |
robertom
Joined: 15 Mar 2016 Posts: 12
|
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19828
|
|
Posted: Wed Apr 06, 2016 1:53 am |
|
|
Repeat again. Have you set the _Windows_ handshaking.
As I have said, I have seen environments, where though the terminal program thinks it is setting the handshaking, it does not get enabled. Do not know why.
I have become paranoid now, and if I want handshaking, always enable it in the device itself, and then in the terminal program. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9472 Location: Greensville,Ontario
|
|
Posted: Wed Apr 06, 2016 6:07 am |
|
|
I have to agree with Mr. T it's a Windows problem. Seems like you have a USB module. Now with XP I've never had a problem using the modules and Hyperterminal,RealTerm or Delphi programs. After XP, windows has become very 'layered' and 'fights' break out over which layer has control over comports. Then there's the 'permission' issues...arrghhhhh.
If possible, grab a 15 year old PC with REAL RS-232 Comports and XP, use as your test PC,odds are real good it WILL work.
If not, then you have to unpeel the Windows Onion System (OS) and make sure EVERY layer and AP is configured properly.And I bet the order you do it in matters too!
Jay |
|
 |
robertom
Joined: 15 Mar 2016 Posts: 12
|
|
Posted: Wed Apr 06, 2016 10:30 pm |
|
|
Greetings,
i could make the example of the bootloader work and it does what it has to.
i wonder if theres an option to increase the size of the bootloader to add some code i tried to modify this #define LOADER_SIZE of loader.c and this #define LOADER_END of bootloader.h
Quote: |
#build (reset=0x400, interrupt=0x408)
#org 0, 0x3FF {} |
Some people use this to move the interrupt vector and to save the bootloader space.
i have modified the parameters but without results, how can i get rid of the ROM error? where i could check what to do? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9472 Location: Greensville,Ontario
|
|
Posted: Thu Apr 07, 2016 5:44 am |
|
|
great, now we're back to square one. You've got the CCS bootloader up and running.
You should never,ever alter or edit the CCS examples ! Simply copy and rename them,do the editting on your versions.
Please explain what 'new features' you want to add to 'my_bootloader.c' After all the bootloader simply takes a program and stuffs into a PIC.
Jay |
|
 |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu Apr 07, 2016 7:22 am |
|
|
Hi,
I find these threads incredibly annoying. The OP engages in lots of back and forth here on the forum - ie. he benefits from the collective wisdom of the forum members - and then suddenly posts something like this:
Quote: |
I could make the example of the bootloader work and it does what it has to
|
Why is that annoying? Because the OP never mentions the 'solution', and instead just charges off into *his* next issue. This makes the thread virtually useless for other users, and people that come after the OP with the same problem.
Moral of the story? Don't be selfish. If you use the forum to solve you problem, do everything you can to make the information exchange a learning experience for others, just as it was for you! _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19828
|
|
Posted: Thu Apr 07, 2016 7:51 am |
|
|
On the question asked about size, the lines posted are not from the CCS driver. If you look, the CCS code references _everything_ to the define 'LOADER_END'. If you want to have larger code, all you need to do is change the value defined in this, _before_ you load bootloader.h, in your files.
So if you wanted to have 0x5FF for your loader, just have:
Code: |
#define LOADER_END 0x5FF
#define _bootloader
#include "bootloader.h"
|
in the bootloader code, and
Code: |
#define _bootloader
#include "bootloader.h"
|
In the program to be loaded.
This then does all the adjustments necessary to where things are placed in both programs.
Remember the size _must_ be the byte below a page boundary on the chip. |
|
 |
robertom
Joined: 15 Mar 2016 Posts: 12
|
|
Posted: Thu Apr 07, 2016 6:07 pm |
|
|
temtronic wrote: | great, now we're back to square one. You've got the CCS bootloader up and running.
You should never,ever alter or edit the CCS examples ! Simply copy and rename them,do the editing on your versions.
Please explain what 'new features' you want to add to 'my_bootloader.c' After all the bootloader simply takes a program and stuffs into a PIC.
Jay |
well i want to do it a bit more remote.
I was thinking to write on the eeprom a value that can be triggered with a specific word through the serial. This will be on the program that will be loaded not in the bootloader and with a reset the first thing that will be read will be this space of the eeprom and act like the pushbutton. |
|
 |
robertom
Joined: 15 Mar 2016 Posts: 12
|
|
Posted: Thu Apr 07, 2016 6:14 pm |
|
|
ezflyr wrote: | Hi,
I find these threads incredibly annoying. The OP engages in lots of back and forth here on the forum - ie. he benefits from the collective wisdom of the forum members - and then suddenly posts something like this:
Quote: |
I could make the example of the bootloader work and it does what it has to
|
Why is that annoying? Because the OP never mentions the 'solution', and instead just charges off into *his* next issue. This makes the thread virtually useless for other users, and people that come after the OP with the same problem.
Moral of the story? Don't be selfish. If you use the forum to solve you problem, do everything you can to make the information exchange a learning experience for others, just as it was for you! |
well indeed it wasnt somethig about the software neither hardware it was a mistake that i made of not reading about the siow.
Fisrt i was trying tera term as the terminal and others like crt with the XON/XOFF that its specified on the loader.c
Code: |
///////////////////////////////////////////////////////////////////////////
//// loader.c ////
//// ////
//// This driver will take an Intel 8-bit Hex file over RS232 channels ////
//// and modify the flash program memory with the new code. A proxy ////
//// function is required to sit between the real loading function ////
//// and the main code because the #org preprocessor command could ////
//// possibly change the order of functions within a defined block. ////
//// ////
//// After each good line, the loader sends an ACKLOD character. The ////
//// driver uses XON/XOFF flow control. Also, any buffer on the PC ////
//// UART must be turned off, or to its lowest setting, otherwise it ////
//// will miss data. ////
//// ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,2014 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
/////////////////////////////////////////////////////////////////////////// |
So the first thing i thougth was to configure this type of comunication.
Moving to siow as the terminal i saw the same basics, the send file option, the paste&transmit and the port options where i configured the XON/XOFF. It was all a mistake until i saw a post about the usb bootloader.
http://4.bp.blogspot.com/-SJYXf5xBSlE/Uu5bDB7CbOI/AAAAAAAAAOQ/uguD-hBINHg/s1600/bootloader3.png
I misunderstood this option and didn't use it, when i loaded the HEX with this option all things work. |
|
 |
|
|
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
|