This shows you the differences between two versions of the page.
— |
project:usb:code:hello_world [2007/04/27 00:21] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Hello World! ====== | ||
+ | For those having trouble getting started on their projects, here is a copy of a "Hello World!" | ||
+ | Connect the LED to pin B7, and **make sure it lights when the PIC pulls it //low//**. | ||
+ | |||
+ | Set your (virtual) terminal to: | ||
+ | ^ Mode | ANSI | | ||
+ | ^ Baudrate | ||
+ | ^ Bits | 7 | | ||
+ | ^ Parity | ||
+ | ^ Stop bits | 1 | | ||
+ | |||
+ | {{project: | ||
+ | |||
+ | <code cpp> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // | ||
+ | // Setup PIC and CCS compiler | ||
+ | #fuses XT, PUT, NOWDT, NOPROTECT | ||
+ | #use delay(clock = 4000000) | ||
+ | |||
+ | #use rs232(baud = 9600, xmit = PIN_C6, rcv = PIN_C7) | ||
+ | // By using C6 and C7, we will make use of the 877's hardware USART abilities | ||
+ | |||
+ | #use standard_io(b) | ||
+ | #byte port_d = 8 | ||
+ | |||
+ | // | ||
+ | // Definitions | ||
+ | #define ON 1 | ||
+ | #define OFF 0 | ||
+ | |||
+ | #define LED_N PIN_B7 | ||
+ | |||
+ | // | ||
+ | // Entry point | ||
+ | void main(void){ | ||
+ | short debug = ON; | ||
+ | |||
+ | output_low(LED_N); | ||
+ | |||
+ | while(debug) | ||
+ | { | ||
+ | printf(" | ||
+ | delay_ms(1000); | ||
+ | output_toggle(LED_N); | ||
+ | } | ||
+ | } | ||
+ | </ |