Compare commits
No commits in common. "e9a2313221412a17196d15c07137b896cf938de9" and "5b62891fd4eb721592ce74eb04af1bc61feb1f94" have entirely different histories.
e9a2313221
...
5b62891fd4
@ -19,7 +19,6 @@
|
|||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import math\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"from __future__ import print_function\n",
|
"from __future__ import print_function\n",
|
||||||
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
|
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
|
||||||
@ -97,16 +96,6 @@
|
|||||||
"# Calculate Temperature from Resistance Value"
|
"# Calculate Temperature from Resistance Value"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"def calculate_temp_for_df(data_frame, resistance_col_name='ext_lf_corr', temp_col_name='temp_calculated'):\n",
|
|
||||||
" data_frame[temp_col_name] = data_frame.apply(lambda row: calc_temp(row[resistance_col_name]) , axis=1)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -115,14 +104,14 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"df_list = [one_k_sampling_trafo, two_k_sampling_trafo, temperature_measurement, constant_sampling]\n",
|
"df_list = [one_k_sampling_trafo, two_k_sampling_trafo, temperature_measurement, constant_sampling]\n",
|
||||||
"for df in df_list:\n",
|
"for df in df_list:\n",
|
||||||
" calculate_temp_for_df(df)\n"
|
" df['temp_calculated'] = df.apply(lambda row: calc_temp(row['ext_lf_corr']) , axis=1)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# Histograms -- Starting from Index 100 (Uncalibrated)"
|
"# Histograms -- Starting from Index 100"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -131,35 +120,18 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(28,20))\n",
|
"fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(28,15))\n",
|
||||||
"plot_data = [(one_k_sampling_trafo, '1 kOhm Sampling Transformer powered', 0), (two_k_sampling_trafo, '2 kOhm Sampling Transformer powered' , 0), (constant_sampling, '1 kOhm Sampling', 100)]\n",
|
"plot_data = [(one_k_sampling_trafo, '1 kOhm Sampling Transformer powered', 0), (two_k_sampling_trafo, '2 kOhm Sampling Transformer powered' , 0), (constant_sampling, '1 kOhm Sampling', 100)]\n",
|
||||||
"signal_list = [('adc_results.pa2_raw', 20), ('ext_lf_corr', 20), ('temp_calculated', 20)]\n",
|
"signal_list = [('adc_results.pa2_raw', 20), ('ext_lf_corr', 20), ('temp_calculated', 20)]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for (data_df, title, start_idx), ax_rows in zip(plot_data, axes):\n",
|
"for (data_df, title, start_idx), ax_rows in zip(plot_data, axes):\n",
|
||||||
" for ax,sig in zip(ax_rows, signal_list):\n",
|
" for ax,sig in zip(ax_rows, signal_list):\n",
|
||||||
" n, bins, patches = ax.hist(data_df[sig[0]][start_idx:], sig[1], density=1, color='navy')\n",
|
" n, bins, patches = ax.hist(data_df[sig[0]][start_idx:], sig[1], density=1)\n",
|
||||||
" mu = np.mean(data_df[sig[0]][start_idx:])\n",
|
" mu = np.mean(data_df[sig[0]][start_idx:])\n",
|
||||||
" sigma = np.std(data_df[sig[0]][start_idx:])\n",
|
" sigma = np.std(data_df[sig[0]][start_idx:])\n",
|
||||||
" y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2))\n",
|
" y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2))\n",
|
||||||
" ax.plot(bins, y, color='darkorange')\n",
|
" ax.plot(bins, y)\n",
|
||||||
" ax.set_title(title)\n",
|
" ax.set_title('Histogram of '+sig[0]+' for '+title)\n",
|
||||||
" ax.set_ylabel(sig[0] + ' probability (normalized)')\n",
|
|
||||||
" ax.set_xlabel(sig[0])\n",
|
|
||||||
" # Plot sigma and mu lines\n",
|
|
||||||
" ax.axvline(x=mu-sigma, ls='--', color='magenta')\n",
|
|
||||||
" ax.axvline(x=mu+sigma, ls='--', color='magenta')\n",
|
|
||||||
" ax.axvline(x=mu, ls='--', color='lawngreen')\n",
|
|
||||||
" \n",
|
|
||||||
" #Plot textbox\n",
|
|
||||||
" textstr = '\\n'.join((\n",
|
|
||||||
" r'$\\mu=%.2f$' % (mu, ),\n",
|
|
||||||
" r'$\\sigma=%.2f$' % (sigma, )))\n",
|
|
||||||
" props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)\n",
|
|
||||||
" ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,\n",
|
|
||||||
" verticalalignment='top', bbox=props)\n",
|
|
||||||
"\n",
|
|
||||||
" \n",
|
|
||||||
"plt.tight_layout()\n",
|
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -189,9 +161,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# Temperature Plotting\n",
|
"# Temperature Plotting"
|
||||||
"\n",
|
|
||||||
"Noise is visible as soon as the temperature sensor is touched or connected to ground in an improper way."
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -204,129 +174,11 @@
|
|||||||
"@interact(low=(0,idx_count -1,10), high=(0, idx_count-1, 10))\n",
|
"@interact(low=(0,idx_count -1,10), high=(0, idx_count-1, 10))\n",
|
||||||
"def plot_temp(low=0, high=idx_count-1):\n",
|
"def plot_temp(low=0, high=idx_count-1):\n",
|
||||||
" fig, ax = plt.subplots(nrows=3, ncols=1, figsize=(28,9*3), sharex=True)\n",
|
" fig, ax = plt.subplots(nrows=3, ncols=1, figsize=(28,9*3), sharex=True)\n",
|
||||||
" ax[0].plot(temperature_measurement['Time'][low:high], temperature_measurement['adc_results.pa2_raw'][low:high])\n",
|
" ax[0].plot(temperature_measurement['Time'][low:high], temperature_measurement['ext_lf_corr'][low:high])\n",
|
||||||
" ax[1].plot(temperature_measurement['Time'][low:high], temperature_measurement['ext_lf_corr'][low:high])\n",
|
" ax[1].plot(temperature_measurement['Time'][low:high], temperature_measurement['adc_results.pa2_raw'][low:high])\n",
|
||||||
" ax[2].plot(temperature_measurement['Time'][low:high], temperature_measurement['temp_calculated'][low:high])\n",
|
" ax[2].plot(temperature_measurement['Time'][low:high], temperature_measurement['temp_calculated'][low:high])\n",
|
||||||
" titles = ['Raw ADC Results', 'Low Pass Filtered Resistance Reading', 'Calculated Low Frequency Temperature']\n",
|
|
||||||
" for i, title in zip(range(0,3), titles):\n",
|
|
||||||
" ax[i].grid()\n",
|
|
||||||
" ax[i].set_title(title)\n",
|
|
||||||
" plt.plot()"
|
" plt.plot()"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"# Temperature Plotting With Proper Grounding of Circuit and the Cable Shield"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"shielded_df = pd.read_csv(r'ContactPT1000HeatgunCooldown.csv')\n",
|
|
||||||
"\n",
|
|
||||||
"# Calculate temperature\n",
|
|
||||||
"calculate_temp_for_df(shielded_df)\n",
|
|
||||||
"\n",
|
|
||||||
"# Derivateve of temp\n",
|
|
||||||
"shielded_df['temp_gradient'] = shielded_df['temp_calculated'].diff() / shielded_df['Time'].diff()\n",
|
|
||||||
"\n",
|
|
||||||
"# Low pass filter gradient with moving average\n",
|
|
||||||
"shielded_df['temp_gradient_lf'] = 0.0\n",
|
|
||||||
"shielded_df['temp_gradient_lf_2'] = 0.0\n",
|
|
||||||
"last_grad_lf = 0.0\n",
|
|
||||||
"\n",
|
|
||||||
"alpha = 0.005\n",
|
|
||||||
"delta_alpha = 0.0\n",
|
|
||||||
"zeta = 20\n",
|
|
||||||
"\n",
|
|
||||||
"for index, row in shielded_df.iterrows():\n",
|
|
||||||
" if index == 0:\n",
|
|
||||||
" pass\n",
|
|
||||||
" else:\n",
|
|
||||||
" current_gradient = row['temp_gradient']\n",
|
|
||||||
" if last_grad_lf != 0.0:\n",
|
|
||||||
" alpha_corr = abs(current_gradient) / zeta * delta_alpha\n",
|
|
||||||
" else:\n",
|
|
||||||
" alpha_corr = 0\n",
|
|
||||||
" last_grad_lf = last_grad_lf * (1-(alpha+alpha_corr)) + (alpha+alpha_corr) * current_gradient\n",
|
|
||||||
" shielded_df.at[index, 'temp_gradient_lf'] = last_grad_lf\n",
|
|
||||||
" \n",
|
|
||||||
"# Derivateve of grad is grad2\n",
|
|
||||||
"shielded_df['temp_gradient_lf_2'] = shielded_df['temp_gradient_lf'].diff() / shielded_df['Time'].diff()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"## Full curve"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"fig, ax = plt.subplots(figsize=(28,9))\n",
|
|
||||||
"tau = 25\n",
|
|
||||||
"tau2 = 0\n",
|
|
||||||
"ax.plot(shielded_df['Time'], shielded_df['temp_calculated'], label='Uncalibrated Temperature')\n",
|
|
||||||
"ax.plot(shielded_df['Time'], shielded_df['temp_calculated']+shielded_df['temp_gradient_lf']*tau + shielded_df['temp_gradient_lf_2']*tau2, label=r'PT1 corrected with $\\tau = %f$' % tau)\n",
|
|
||||||
"ax.grid()\n",
|
|
||||||
"ax.legend()\n",
|
|
||||||
"ax.set_title('Temperature measurement with proper ground connection')\n",
|
|
||||||
"plt.show()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"## Temperature Gradient"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"fig, ax = plt.subplots(figsize=(28,8))\n",
|
|
||||||
"tau = 30\n",
|
|
||||||
"ax.plot(shielded_df['Time'], shielded_df['temp_gradient'], label=r\"$\\dot{\\vartheta} = \\frac{\\partial\\vartheta}{\\partial t}$\")\n",
|
|
||||||
"ax.plot(shielded_df['Time'], shielded_df['temp_gradient_lf'], label=r'$\\tilde{\\dot{\\vartheta}}$')\n",
|
|
||||||
"ax.legend()\n",
|
|
||||||
"plt.show()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"## Cooldown to Room Temperature in Detail"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"fig, ax = plt.subplots(figsize=(28,9))\n",
|
|
||||||
"start_time = -320\n",
|
|
||||||
"filtered_cooldown = shielded_df[shielded_df['Time'] > start_time]\n",
|
|
||||||
"ax.plot(filtered_cooldown['Time'], filtered_cooldown['temp_calculated'], label='Measured Cooldown')\n",
|
|
||||||
"ax.plot(filtered_cooldown['Time'], filtered_cooldown['temp_calculated']+filtered_cooldown['temp_gradient_lf']*tau, label='Calculated Exterior Temperature')\n",
|
|
||||||
"ax.grid()\n",
|
|
||||||
"ax.set_title('Cooldown without airflow | Convection has to be taken into account') \n",
|
|
||||||
"plt.show()"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
File diff suppressed because it is too large
Load Diff
287
stm-firmware/reflow-oven-controller.jdebug
Normal file
287
stm-firmware/reflow-oven-controller.jdebug
Normal file
@ -0,0 +1,287 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* (c) SEGGER Microcontroller GmbH *
|
||||||
|
* The Embedded Experts *
|
||||||
|
* www.segger.com *
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
File :
|
||||||
|
Created : 26 Jan 2020 15:46
|
||||||
|
Ozone Version : V2.70
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* OnProjectLoad
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Project load routine. Required.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
void OnProjectLoad (void) {
|
||||||
|
//
|
||||||
|
// Dialog-generated settings
|
||||||
|
//
|
||||||
|
Project.AddPathSubstitute ("/home/mari/projects/arm/reflow-oven-controller", "$(ProjectDir)");
|
||||||
|
Project.AddPathSubstitute ("/home/mari/projects/arm/reflow-oven-controller", "$(ProjectDir)");
|
||||||
|
Project.SetDevice ("STM32F407VE");
|
||||||
|
Project.SetHostIF ("USB", "");
|
||||||
|
Project.SetTargetIF ("SWD");
|
||||||
|
Project.SetTIFSpeed ("4 MHz");
|
||||||
|
Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd");
|
||||||
|
Project.AddSvdFile ("/home/mari/Downloads/STM32F407.svd");
|
||||||
|
//
|
||||||
|
// User settings
|
||||||
|
//
|
||||||
|
File.Open ("$(ProjectDir)/reflow-controller.elf");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* OnSnapshotLoad
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Optional event handler, called upon loading a snapshot.
|
||||||
|
*
|
||||||
|
* Additional information
|
||||||
|
* This function is used to restore the target state in cases
|
||||||
|
* where values cannot simply be written to the target.
|
||||||
|
* Typical use: GPIO clock needs to be enabled, before
|
||||||
|
* GPIO is configured.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void OnSnapshotLoad (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* OnSnapshotSave
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Optional event handler, called upon saving a snapshot.
|
||||||
|
*
|
||||||
|
* Additional information
|
||||||
|
* This function is usually used to save values of the target
|
||||||
|
* state which can either not be trivially read,
|
||||||
|
* or need to be restored in a specific way or order.
|
||||||
|
* Typically use: Memory Mapped Registers,
|
||||||
|
* such as PLL and GPIO configuration.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void OnSnapshotSave (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* TargetReset
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Replaces the default target device reset routine. Optional.
|
||||||
|
*
|
||||||
|
* Notes
|
||||||
|
* This example demonstrates the usage when
|
||||||
|
* debugging a RAM program on a Cortex-M target device
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void TargetReset (void) {
|
||||||
|
//
|
||||||
|
// unsigned int SP;
|
||||||
|
// unsigned int PC;
|
||||||
|
// unsigned int VectorTableAddr;
|
||||||
|
//
|
||||||
|
// Exec.Reset();
|
||||||
|
//
|
||||||
|
// VectorTableAddr = Elf.GetBaseAddr();
|
||||||
|
//
|
||||||
|
// if (VectorTableAddr != 0xFFFFFFFF) {
|
||||||
|
//
|
||||||
|
// Util.Log("Resetting Program.");
|
||||||
|
//
|
||||||
|
// SP = Target.ReadU32(VectorTableAddr);
|
||||||
|
// Target.SetReg("SP", SP);
|
||||||
|
//
|
||||||
|
// PC = Target.ReadU32(VectorTableAddr + 4);
|
||||||
|
// Target.SetReg("PC", PC);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* BeforeTargetReset
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void BeforeTargetReset (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* AfterTargetReset
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine.
|
||||||
|
* - Sets the PC register to program reset value.
|
||||||
|
* - Sets the SP register to program reset value on Cortex-M.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
void AfterTargetReset (void) {
|
||||||
|
unsigned int SP;
|
||||||
|
unsigned int PC;
|
||||||
|
unsigned int VectorTableAddr;
|
||||||
|
|
||||||
|
VectorTableAddr = Elf.GetBaseAddr();
|
||||||
|
|
||||||
|
if (VectorTableAddr == 0xFFFFFFFF) {
|
||||||
|
Util.Log("Project file error: failed to get program base");
|
||||||
|
} else {
|
||||||
|
SP = Target.ReadU32(VectorTableAddr);
|
||||||
|
Target.SetReg("SP", SP);
|
||||||
|
|
||||||
|
PC = Target.ReadU32(VectorTableAddr + 4);
|
||||||
|
Target.SetReg("PC", PC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* DebugStart
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Replaces the default debug session startup routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void DebugStart (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* TargetConnect
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Replaces the default target IF connection routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void TargetConnect (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* BeforeTargetConnect
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void BeforeTargetConnect (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* AfterTargetConnect
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void AfterTargetConnect (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* TargetDownload
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Replaces the default program download routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void TargetDownload (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* BeforeTargetDownload
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void BeforeTargetDownload (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* AfterTargetDownload
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine.
|
||||||
|
* - Sets the PC register to program reset value.
|
||||||
|
* - Sets the SP register to program reset value on Cortex-M.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
void AfterTargetDownload (void) {
|
||||||
|
unsigned int SP;
|
||||||
|
unsigned int PC;
|
||||||
|
unsigned int VectorTableAddr;
|
||||||
|
|
||||||
|
VectorTableAddr = Elf.GetBaseAddr();
|
||||||
|
|
||||||
|
if (VectorTableAddr == 0xFFFFFFFF) {
|
||||||
|
Util.Log("Project file error: failed to get program base");
|
||||||
|
} else {
|
||||||
|
SP = Target.ReadU32(VectorTableAddr);
|
||||||
|
Target.SetReg("SP", SP);
|
||||||
|
|
||||||
|
PC = Target.ReadU32(VectorTableAddr + 4);
|
||||||
|
Target.SetReg("PC", PC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* BeforeTargetDisconnect
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void BeforeTargetDisconnect (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* AfterTargetDisconnect
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void AfterTargetDisconnect (void) {
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
*
|
||||||
|
* AfterTargetHalt
|
||||||
|
*
|
||||||
|
* Function description
|
||||||
|
* Event handler routine. Optional.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
//void AfterTargetHalt (void) {
|
||||||
|
//}
|
Loading…
x
Reference in New Issue
Block a user