-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does my code stop when I connect minichlink terminal? #302
Comments
What happen if u comment out the console output? I had issues with printf in the past. |
@unicab369 tried to test out your theory today and it got even weirder. First I tried to just run my code again to make sure the problem still persists, and what ended up happening - it started to work as it should. But only about ~30% of the time. Removed all printf from my code and it didn't make any difference. This latest issue happens with this code: void initLED(){
GPIO_port_enable(GPIO_port_D);
GPIOB = GPIOv_from_PORT_PIN(GPIO_port_D, 5);
GPIOG = GPIOv_from_PORT_PIN(GPIO_port_D, 6);
GPIOR = GPIOv_from_PORT_PIN(GPIO_port_D, 4);
GPIO_pinMode(GPIOB, GPIO_pinMode_O_pushPull, GPIO_Speed_10MHz);
GPIO_pinMode(GPIOG, GPIO_pinMode_O_pushPull, GPIO_Speed_10MHz);
GPIO_pinMode(GPIOR, GPIO_pinMode_O_pushPull, GPIO_Speed_10MHz);
}
int main() {
SystemInit();
// initI2C();
initLED();
while (1) {
GPIO_digitalWrite(GPIOR, high);
GPIO_digitalWrite(GPIOG, high);
GPIO_digitalWrite(GPIOB, high);
Delay_Ms( 200 );
GPIO_digitalWrite(GPIOR, low);
GPIO_digitalWrite(GPIOG, low);
GPIO_digitalWrite(GPIOB, low);
Delay_Ms( 200 );
} // Do not let main exit, you can do other things here
} And only with this code. If I comment out two LED's and leave only one blinking then I'm back to freezing. This is so weird and inconsistent. |
I just wanted to add for mine: I also have an I2C slave running receiving data, entire code doesn't run at all when there's no at least 5 I'll continue to look into it, but thought I'd comment about it here, seems like I'm not the only one with |
This is worth having a deeper discussion on - what would you hope the behavior to be? We don't want to drop print() messages because we missed a window on the host PC, so the attitude is we can wait for a while and if it doesn't come out, then we keep going. If we don't pause until the first printf read, and you did a bunch of printf's at start, then they would get missed. I'm up for any behavior, and they're all pretty easy, but just don't know what the correct behavior should be. |
@QuartzAl how do you feel about an explicit attach function? I.e. "Please wait up to n milliseconds" for the debugger/semihost to attach so you can printf things, and if it doesn't attach, then, prints won't wait at all, until a terminal does attach? |
@cnlohr that's a pretty cool idea, and would definitely help. Reminds me of how arduino handles debug messages, if I'm not wrong, upon boot the device checks for anything connected if there is a debugger it connects, otherwise it doesn't care and continues. Though an explicit function like that would probably be better, allows for debugger connection in the middle of code execution? Plus removes the delay issue. Not sure how any of that works, but it sounds cool |
Well, I think
I guess one thing I would want to consider is, what if there is NO additional state within ch32v003fun, and the current printf behavior remains the same - but now this function would let you manually use it or not. |
if no additional state is wanted giving this kind of function sounds like a good idea, the checks could be a user choice to make. I'm all in for this function being implemented |
I have some console output I show when receiving I2C data. Whenever I start
./minichlink -i -T
my IC freezes and I get no output. If I delete the blinking LED code fromwhile
then everything works.Doesn't work:
Works:
The text was updated successfully, but these errors were encountered: