منتديات الهندسة الكهربية والإلكترونية والميكاترونكس والكومبيوتر
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C

اذهب الى الأسفل

الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C   Empty الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C

مُساهمة من طرف Admin الثلاثاء مايو 05, 2015 2:10 pm

الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C


الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C   127


الاتصال بين الميكروكونترولر PIC والكمبيوتر PC والمحاكاة ببرنامج ISIS مع المترجم CCS C   223

البرنامج :

الكود:

/******************************************************
    PIC16F877 RS232 Serial Communication Application
*******************************************************/
#include <16f877.h>    //
#use delay (clock=4000000) //
#define use_portb_lcd TRUE  //
#include <lcd.c>  //
#use rs232 (baud=9600, xmit=pin_C6, rcv=pin_C7, parity=N, stop=1)
// RS232 protocol 9600 bit/s
// TX, RX pins as defined , C6,C7
// no parity bit , stop 1 bit

char keyboard[80];  // defined an array name keyboard with 80-element

#int_rda // Receive data available Interrupt 
void rda_isr () // When Receive data available do :
{
  disable_interrupts(int_rda); // Disables the specified interrupt
  output_high(pin_c5);  // Set pin RC5 to logic 1
  gets(keyboard);
  //gets (string), Reads characters (using GETC()) into the string
  //until a RETURN (value 13) is encountered
  // Read or Receive array string "keyboard" .
  printf("\n\rYou wrote the text>  %s\n",keyboard);
  // new line , new row , send the string expressions and array keyboard via RS232,then new line
  printf(lcd_putc,"\f%s",keyboard);  //Clear LCD and display keyboard array string .
  output_low(pin_c5); // Set pin RC5 to logic 0
  printf("\n\rEnter the text from the keyboard and enter key to exit>"); // new line,from start ,send the text string via RS232
}

/********* Main function********/

void main ( )
{
 
  output_low(pin_c5); // Initially RC5 LED => off and on in ISR
  lcd_init();  //

  printf("\r**************** Hello *********************"); //New lines end specified text via RS232 .
  printf("\n\rWhen you enter data from the keyboard will appear on the LCD\n\n"); //new line,from start send specified text via RS232 .
  printf("\n\rEnter the text from the keyboard and enter key to exit>"); //new line,from start send specified text via RS232.
 
  enable_interrupts(GLOBAL);  // enable all interrupts

  while(1) // endless loop
  {
      enable_interrupts(int_rda); // enable rda interrupt
  }
}


Admin
Admin

عدد المساهمات : 1194
تاريخ التسجيل : 28/01/2014

https://fathallaabdelaziz.forumarabia.com

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى