Cantafford
Member
Hello. I'm playing with a dsPIC30F2010 and I wanted to make a led blink. I wrote this code:
When I run this code I get the following error:
main.c:19: error: 'for' loop initial declaration used outside C99 mode
I tried initialising the 'delay' variable outside the loop. Still get that error.
When I program PIC's, not dsPIC's and I write such a loop to get a delay I don't get that error. I only get it when I'm using the dsPIC programmer. Any ideea why? Thanks for reading.
Code:
#include <stdio.h>
#include <stdlib.h>
#include "header.h"
void main()
{
TRISB = 0;
while(1)
{
LATBbits.LATB0 = 1;
for(int delay=0; delay<2; delay++) __delay_ms(5);
}
}
When I run this code I get the following error:
main.c:19: error: 'for' loop initial declaration used outside C99 mode
I tried initialising the 'delay' variable outside the loop. Still get that error.
When I program PIC's, not dsPIC's and I write such a loop to get a delay I don't get that error. I only get it when I'm using the dsPIC programmer. Any ideea why? Thanks for reading.