BDM vs. Serial

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

BDM vs. Serial

4,706 次查看
Shugie
Contributor I
In the past I have been loading all my code on to HC12 microcontrollers through the freescale serial bootloader. Recently I decided to try a BDM to try to make debugging and loading easier. However I have come across a problem. When I erase the memory with the BDM and reprogram the micro, it does not work. However, If I reload the serial monitor, then load the code over the serial, it does work. None of the other solutions to similar posts on this forum have helped so far. I was wondering if I have to write a bootloader to jump to the start of my code or if there was a problem in my memory map file because Codewarrior used to just have the serial_monitor target. I guess I don't really understand what happens in the registers (PC, IC, and others) after a reset or I don't understand how/where the BDM loads the code. Thank you all in advance.
标签 (1)
0 项奖励
回复
4 回复数

1,648 次查看
Shugie
Contributor I
I think the problem was in setting up the memory. I did have to make some modifications to ensure the PLL is being set up correctly. All of the tips so far have been very helpful.

Everything works now as long as my watchdog timer is off. The manual says that the reset vectors of the watchdog are different than the manual reset vectors, but I don't see anything in the serial monitor that does anything special for the watchdog.

Message Edited by Shugie on 2007-07-09 03:08 PM
0 项奖励
回复

1,648 次查看
mjbcswitzerland
Specialist V
Hi

Check that you are setting up your memory correctly (eg. the location of RAM).
The serial  monitor program does this as almost first job when it starts and so even if your code is not doing it you will not notice it and all will run correctly.
Once however you move to BDM it is your own code which is booting and so if such initialisations are missing it will then not work.
This is a typical mistake which is not noticed when working with the serial monitor since it is doing some set up itself.

regards

Mark

www.uTasker.com


0 项奖励
回复

1,648 次查看
JimDon
Senior Contributor III
There is also the issue of the clock setting.

SerMon cranks the PLL for you, so you must set the PLL up yourself.
speed the frequency of the xtal 4,8 or 16.

void PLL_Init(byte speed)
{

 
  // PLLCLK = 2 * OSCCLK * (SYNR + 1) / (REFDV + 1)
  // We want OSCCLK *  (SYNR + 1) / (REFDV + 1) to be 24

  if( 16 == speed )
  {
      SYNR  = 0x02;       // 16/(1+1) * (2+1) = 24  
      REFDV = 0x01;
  } else if( 8 == speed )
  {
      SYNR  = 0x02;       // 8/(0+1) * (2+1) = 24
      REFDV = 0x00;
  } else if( 4 == speed )
  {
      SYNR  = 0x05;       // 4/(0+1) * (5+1) = 24
      REFDV = 0x00;
  }
   else
     return;
 
  CLKSEL = 0x00;
  PLLCTL = 0xD1;  // Turn on PLL Clk
 

  while((CRGFLG&0x08) == 0)       // Wait for PLLCLK to stabilize.
        ;       

  CLKSEL_PLLSEL = 1;  // Switch to PLL clock
}
Submit Post


0 项奖励
回复

1,648 次查看
stevo10
Contributor I
Hi,

I'm not sure how much this will help but here is a link to an application note, it was written with 8-bit MCUs in mind, but the principals of BDM are the same.

http://www.freescale.com/files/microcontrollers/doc/app_note/AN3335.pdf?fsrch=1


0 项奖励
回复