SHARE
TWEET

solarwind

a guest Feb 20th, 2009 1,823 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <p18cxxx.h>
  2. #include <stdio.h>
  3. #include "LCD.h"
  4. #include "main.h"
  5. #include "delay.h"
  6.  
  7. #pragma config OSC = INTIO67  //Internal oscillator
  8. #pragma config FCMEN = OFF
  9. #pragma config IESO = OFF
  10. #pragma config PWRT = ON
  11. #pragma config BOREN = OFF
  12. #pragma config WDT = OFF
  13. #pragma config MCLRE = OFF
  14. #pragma config PBADEN = OFF
  15. #pragma config LVP = OFF
  16.  
  17. //User defined putc for user defined output stream
  18. void _user_putc(unsigned char c) {
  19.         send_data(c);
  20. }
  21.  
  22. void main() {
  23.         OSCCON = 0b01110000; //8 MHz
  24.         OSCTUNE = 0b01011111; //PLL is enabled, maximum frequency
  25.        
  26.         TRISC = 0x00;
  27.         stdout = _H_USER;
  28.  
  29.         lcd_init(); //Initialize the LCD
  30.         send_cmd(0x0C); //Turn off cursor
  31.         set_cursor(1, 1);
  32.         printf("Hello world!");
  33.  
  34.         send_cmd(0x40 + 0); //Set character RAM address to zero
  35.         send_data(0b00000); //Define our first character
  36.         send_data(0b00100);
  37.         send_data(0b00010);
  38.         send_data(0b11111);
  39.         send_data(0b00010);
  40.         send_data(0b00100);
  41.         send_data(0b00000);
  42.         send_data(0b00000);
  43.  
  44.         set_cursor(2, 1); //Set the display pointer to a valid position on the LCD
  45.         send_data(0x00); //Display our first character 
  46.        
  47.         while(1);
  48. }
RAW Paste Data
Want to get better at C?
Learn to code C in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top