Hello, Strange Problem.
Win10 i5 loads of ram STLINK V3
I have several STM32F411CE projects i am currently working and this evening after major PC Win 10 rebuild I tried to Edit, Compile and Upload one of them. The program compiles just fine then the process just stops and makes no attempt to upload the program which is about 150 lines including blanks and comment. I have appended it but please don't be critical as is work in progress. The program however compiled and upload just fine with IDE2 RC4 couple of days ago.
So I tried the simple blink example on a NANO and it compiled and uploaded fine, then I recompiled and upload blinky to the STM32F411CE and it worked just fine.
So i opened up the little 150 line com app i am working on and it complies, but just ignores the upload phased.
PS I there a download location for RC4 as I use it and await rc6
Many thanks in advance IMK
#include <arduino.h>
#define OUTPUT_TEST_PIN PC13 // Black Pill STM32411CE (LED)
#define LED_BUILTIN_BLACK_PILL OUTPUT_TEST_PIN
#define TRUE 1
#define FALSE 0
#define OUTPUT_MSG_SIZE 128
#define MAX_NUMBER_OF_MSGS_IN_OUTPUT_QUEUE 8
struct OutPutMsg
{
char Msg[ OUTPUT_MSG_SIZE ];
};
struct OutPutMsgQueue
{
int NextMsgInIdx;
int NextMsgOutIdx;
struct OutPutMsg OutPutMsgQueueItem[ MAX_NUMBER_OF_MSGS_IN_OUTPUT_QUEUE ];
};
struct OutPutMsgQueue OutPutMsgQueue;
void WriteMsgToOutPutQueue( char TheMsg[] );
int ReadMsgFromOutPutQueue( char TheMsg[] );
//#define MS_WAIT_BEFORE_REPLY 100 // Ran 1hr ok, sometime get bad rx msg so changed to 50 for testing
#define MS_WAIT_BEFORE_REPLY 50 // // This works much better as no skipped messages
//#define MS_WAIT_BEFORE_REPLY 25 //
//#define MS_WAIT_BEFORE_REPLY 10
volatile int RxStringComplete = FALSE;
void OneMilliSecIntFromTimer( void );
HardwareSerial Serial2( PA3 , PA2 ); // Rx Tx
// ------------------------------------- WriteMsgToOutPutQueue() ---------------------------------------
void WriteMsgToOutPutQueue( char TheMsg[] )
{
strcpy( OutPutMsgQueue.OutPutMsgQueueItem[ OutPutMsgQueue.NextMsgInIdx++ ].Msg , TheMsg );
if( OutPutMsgQueue.NextMsgInIdx >= MAX_NUMBER_OF_MSGS_IN_OUTPUT_QUEUE ) // See if queue has wrapped
OutPutMsgQueue.NextMsgInIdx = 0;
}
// -------------------------------------- ReadMsgFromOutPutQueue() -------------------------------------
int ReadMsgFromOutPutQueue( char TheMsg[] )
{
if( OutPutMsgQueue.NextMsgOutIdx != OutPutMsgQueue.NextMsgInIdx ) // See if msg in queue
{ // Yip got one to get
strcpy( TheMsg , OutPutMsgQueue.OutPutMsgQueueItem[ OutPutMsgQueue.NextMsgOutIdx++ ].Msg ); // copy message
if( OutPutMsgQueue.NextMsgOutIdx >= MAX_NUMBER_OF_MSGS_IN_OUTPUT_QUEUE ) // See if queue has wrapped
OutPutMsgQueue.NextMsgOutIdx = 0;
}
else
return( FALSE ); // No msg in Queue
return( TRUE ); // // Returned caller a msg from Queue
}
// --------------------------------------------------------- setup() ------------------------------------------
void setup()
{
pinMode(LED_BUILTIN_BLACK_PILL, OUTPUT);
TIM_TypeDef *Instance = TIM1; // or TIM2, But T2 is used by PWM Motor Control
Serial1.begin( 38400 );
Serial2.begin( 38400 ); // Second serial port TX PA2 RX PA3
// Instantiate HardwareTimer object. Thanks to 'new' instanciation, HardwareTimer is not destructed when setup() function is finished.
HardwareTimer *MyTim = new HardwareTimer(Instance);
MyTim->setOverflow( 1000 , HERTZ_FORMAT); // 1000 Hz
MyTim->attachInterrupt( OneMilliSecIntFromTimer );
MyTim->resume(); // Set the interrupt Timer
//Serial1.print( SlaveTxMsg );
}
volatile int HostMsgRxed; // tmp flag
char FromHostRxMsgBuf[128];
int FromHostRxMsgIdx;
// ------------------------------------------ loop() -------------------------------
void loop()
{
if( HostMsgRxed && RxStringComplete ) // See if a msg from the host
{
delay( MS_WAIT_BEFORE_REPLY ); // Radio Modem Minimum Turn aRound Time
RxStringComplete = FALSE;
HostMsgRxed = FALSE;
Serial1.print( FromHostRxMsgBuf );
// Serial2.print( "123" ); // For testing
//Serial2.println( ); // For testing
}
delay(1);
}
// ------------------------------------------------ OneMilliSecIntFromTimer() ------------------------------------
void OneMilliSecIntFromTimer( void )
{ // Toggle pin. 10hz toogle --> 5Hz PWM
char RxChar;
//static char RxMsgBuf[128];
//static int RxMsgIdx;
// Rx message from host to be sent in time slot to ERIN Motor Sensors
while( Serial2.available() )
{
RxChar = Serial2.read();
FromHostRxMsgBuf[ FromHostRxMsgIdx++ ] = RxChar;
if( RxChar == '\n' )
{
// digitalWrite( LED_BUILTIN_BLACK_PILL , !digitalRead( LED_BUILTIN_BLACK_PILL ) );
FromHostRxMsgBuf[ FromHostRxMsgIdx ] = 0;
HostMsgRxed = TRUE;
FromHostRxMsgIdx = 0;
// RxMsgIdx = 0;
}
} // end while have data Serial 1
// Rx message from ERIN Motor Sensor.... Msg end is just just to creat message send from host time slot
while( Serial1.available() )
{
RxChar = Serial1.read();
//RxMsgBuf[ RxMsgIdx++ ] = RxChar;
if( RxChar == '\n' )
{
// RxMsgIdx = 0;
if( HostMsgRxed )
{ // Got a host msg so wait until we have rx ERIN M/S msg to sync with
RxStringComplete = TRUE;
digitalWrite( LED_BUILTIN_BLACK_PILL , !digitalRead( LED_BUILTIN_BLACK_PILL ) );
}
}
} // end while have data Serial 1
} // End OneMilliSecIntFromTimer() Proc