I've got a simple program that compiles and runs perfectly when I use in Energia:
. . . void setup() { // setup } void loop() { // loop }
But when I convert to the C syntax:
. . . int main() { // setup while (1) { // loop } }
I get from Energia during compilation:
Here is the full program:
# include "inc/tm4c123gh6pm.h" # include <stdint.h> # include <stdbool.h> # include "inc/hw_gpio.h" # include "inc/hw_memmap.h" # include "inc/hw_sysctl.h" # include "inc/hw_types.h" # include "driverlib/gpio.h" # include "driverlib/sysctl.h" #define LED_RED GPIO_PIN_1 #define LED_BLUE GPIO_PIN_2 #define LED_GREEN GPIO_PIN_3 #define EXTERNAL_LED GPIO_PIN_3 #define PUSH_BUTTON GPIO_PIN_4 #define readSW1 (!(GPIO_PORTF_DATA_R & PUSH_BUTTON)) #define TimebaseMs 4000 void WaitMs (int Amount) { volatile int j; int i; for (i=0;i<Amount;i++) { for (j=0;j<TimebaseMs;j++) { // Wait 1 ms } } } int SW1_now; int SW1_before; int main() { SysCtlClockSet(SYSCTL_SYSDIV_3|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); // enable PORT F GPIO peripheral SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF|SYSCTL_RCGC2_GPIOB; // set LED PORT F pins as outputs GPIO_PORTF_DIR_R |= LED_RED | LED_BLUE | LED_GREEN; // Outputs for the LEDs GPIO_PORTB_DIR_R = EXTERNAL_LED; // Output for the external LED GPIO_PORTF_DIR_R &=~ PUSH_BUTTON; // Pusbutton as input GPIO_PORTF_PUR_R |= PUSH_BUTTON; // Pushbutton pullup resistor // enable digital for LED PORT F pins GPIO_PORTF_DEN_R = LED_RED|LED_BLUE|LED_GREEN|PUSH_BUTTON; GPIO_PORTB_DEN_R = EXTERNAL_LED; // clear all PORT F pins GPIO_PORTF_DATA_R = 0; GPIO_PORTB_DATA_R = 0; // set LED PORT F pins high GPIO_PORTF_DATA_R |= LED_RED|LED_BLUE|LED_GREEN; GPIO_PORTF_DATA_R &=~ LED_BLUE; GPIO_PORTB_DATA_R |= (1<<3); // Init switch SW1_before = readSW1; // loop forever while(1) { GPIO_PORTB_DATA_R ^= EXTERNAL_LED; WaitMs(1000); } }
Why am I getting this error?