diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 9f1bb2e..db99abd 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -2462,7 +2462,20 @@ int arm7_9_write_memory(struct target *target, uint32_t address, uint32_t size,
 				if (arm7_9->fast_memory_access)
 					retval = arm7_9_execute_fast_sys_speed(target);
 				else
+				{
 					retval = arm7_9_execute_sys_speed(target);
+
+					/*
+					 * if memory writes are made when the clock is running slow
+					 * (i.e. 32 kHz) which is necessary in some scripts to reconfigure
+					 * processor operations after a "reset halt" or "reset init",
+					 * need to immediately stroke the keep alive or will end up with
+					 * gdb "keep alive not sent error message" problem.
+					 */
+
+					keep_alive();
+				}
+
 				if (retval != ERROR_OK)
 				{
 					return retval;
@@ -2498,7 +2511,20 @@ int arm7_9_write_memory(struct target *target, uint32_t address, uint32_t size,
 					if (arm7_9->fast_memory_access)
 						retval = arm7_9_execute_fast_sys_speed(target);
 					else
+					{
 						retval = arm7_9_execute_sys_speed(target);
+
+	                                        /*
+        	                                 * if memory writes are made when the clock is running slow
+                	                         * (i.e. 32 kHz) which is necessary in some scripts to reconfigure
+                        	                 * processor operations after a "reset halt" or "reset init",
+                                	         * need to immediately stroke the keep alive or will end up with
+                                	         * gdb "keep alive not sent error message" problem.
+                                        	 */     
+
+                                      		keep_alive();
+					}
+
 					if (retval != ERROR_OK)
 					{
 						return retval;
@@ -2533,7 +2559,20 @@ int arm7_9_write_memory(struct target *target, uint32_t address, uint32_t size,
 					if (arm7_9->fast_memory_access)
 						retval = arm7_9_execute_fast_sys_speed(target);
 					else
-						retval = arm7_9_execute_sys_speed(target);
+                                        {
+                                                retval = arm7_9_execute_sys_speed(target);
+
+                                                /*
+                                                 * if memory writes are made when the clock is running slow
+                                                 * (i.e. 32 kHz) which is necessary in some scripts to reconfigure
+                                                 * processor operations after a "reset halt" or "reset init",
+                                                 * need to immediately stroke the keep alive or will end up with
+                                                 * gdb "keep alive not sent error message" problem.
+                                                 */
+
+                                                keep_alive();
+                                        }
+
 					if (retval != ERROR_OK)
 					{
 						return retval;
