Programming M16C/65 with fdt over serial interface

Hello everyone,

Im working on aproject where i use M16C/65 (R5F3651NDFC) controller. I want to be able to flash the .mot file with FDT Simple Interface using a UART connection on RXD/TXD1. Between the controller and the computer is the VNC2 USB-Device from FTDI. I tried several settings the last days. The only one that lastly works is with device R5F3651NB_7Line and a bausrate of 9600bps. And thas is very slow. it takes almost 30mins to flash the .mot file. When I use higher baudrates like 38400 or 57600 i get the following Error:

Clock Frequency (External) = N/A, Clock Mode = N/A, CKM = N/A, and CKP = N/A
Connecting to device 'R5F3651NB_7Line' on 'COM9'
'BOOT Mode' connection - using emulated interface
Opening port 'COM9' ...
Loading Comms DLL
Loaded Comms DLL
Initiating BOOT SCI sequence
Attempting 9600
Attempting 4800
Changing baud rate to 57600 bps
Error No 15005: 'COM9' read time out

I use the version : FDT V.4.09 Release 03

How can I Solve this?

Thanks in advance

  • Hi TB,

    Have you finally resolved this issue? It seems that you can't connect to the target device. Did you try to check the connection or try to use another RS-232C transceiver?

    RenesasRulz Forum Moderator
  • In reply to JB:

    Hi JB,
    No unfortunately not yet. Yes I checked the connection and it works fine. Like I said I can flash the device but only with 9600 bps what is very slow(takes almost 1h to flasch the mcu). The RS232 Transceiver I use is on the Target Board (VNC2 IC). The Problem is I cant set higher baudrate than 9600 bps.

  • In reply to TB:

    What is the operating speed of your processor? It looks tom me like you have a quite low oscillator frequency. In your protocol synchronisation is only at 4800 Baud. This is already a bad sign as usually synchronisation happens at 9600 Baud.
    In boot mode the processor runs on external clock without PLL. You can check if you can get proper value for BRG register by calculating ((Oscillator frequency f(Xin) / 16) / baud rate value).
    For example with 20MHz oscillator and 57600 Baud you get a BRG value of 21.7 . If the boot loader uses 22 the speed is 1.4% wrong, if it uses 21 the speed it is 3.2% wrong. Both should work fine.
    If you use 10MHz oscillator and 57600 Baud you get a BRG value of 10.85 . If the boot loader uses 11 the speed is again 1.4% wrong and it should work. But if it uses 10 the speed it is 7,8% wrong and it will not work any more.
    So it depends heavily on the oscillator speed you selected. Lower oscillator frequencies will be more critical.
    I cannot say if the boot loader selects the higher or lower value for BRG setting as I don't know the implementation details.

    The better solution is to use E8 or E8a for programming. E8 and E8a use synchronous serial communication. This does not depend on internally generated baud rates but the communication clock is generated by E8/E8a.
  • In reply to FrankL:

    Hello Frank,
    Thanks for your explanation. So I have a 16MHZ oscillator on my board which means the calculated BRG=26,04. The Baudrate of UART1 before entering boot-mode is set at u1brg=25. So if I choose 38400 Baud to flash the mcu, I have an error of 1,04% what should be ok right? Where can I see which BRG setting the boot loader selects?
    I want this because our customers wish to update the machines by themselves but dont have E8a at their disposal.
    Best regards
  • In reply to TB:

    If u1brg is set to 25 you have an error of 0.15% (register value = calculated value -1).
    You cannot see the BRG value the boot loader selects. UiBRG is a write only register. You have to read the boot loader using a parallel mode programmer, disassemble it to find the sequence where the UART is synchronized, run it in a debugger to this point, and check what is written to U1BRG.
    In M16C/65 you can place your own boot loader in Program ROM 2. Then you can control what is written to U1BRG.
  • In reply to FrankL:

    Unfortunately i dont have any parallel mode programmer. So the last thing I sould try is to place my own boot loader in Program ROM 2. Do you have some intructions how it works? A sample program how to place the bootloader and set the the value of UBRG would be helpful.

    Thanks and best regards.
  • In reply to TB:

    Did you have a look at M16C/65 sample codes?
    This one explains about user boot to program a file downloaded from PC using XMODEM.

  • In reply to FrankL:

    Morning FranKL,
    Yes I already had a look at this sample Program. But I still don´t get what I should do. In this sample it is explaines how to rewrite program ROM1 using UART0 in EW0 mode in user boot function. And you said above I should place my own bootloader in program ROM2 to control what is written in U1BRG. By the way in the application note they said: "In user boot mode, the program written into the program ROM 2 area (starts from 10000h) on flash
    memory is executed." So I´m a little bit confused. Could you explain that to me what the steps are?
    Best regards
  • In reply to TB:


    Has your question been answered?

    Mike Clements
    RensasRulz Moderator
  • In reply to TB:

    This thread will be archived due to inactivity.

    Mike Clements
    RenesasRulz Moderator
  • In reply to Mike Clements:

    Hello Mike.
    Yes the issue has been solved. The fact is, i can´t change the baudrate when programming over uart through the vnc device. The Baudrate i use is 9600.