Home Forums C Programming input output data using rs232

Viewing 0 reply threads
  • Author
    Posts
    • #2011
      pathaksujit
      Participant

      hai everyone…
      need a help here…my coding have a lots of errors but i don’t know how to solve it..my coding is about receive data and sending data using rs232…

      cheers for any help …. Smile

      #include "C:Documents and SettingsPC2Desktopmain system amrmeter.h"
      #include <18F6720.h>
      #use delay(clock=20000000)
      #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)


      void received_req(void);
      void reply_data(void);
      int process;


      #int_RDA
      void RDA_isr(void)
      {
      int i;
      char c;
      c = getc(); //rx data
      for (i=0; i!=c; i++)
      {
      putc(c);
      }
      process = 1;
      }

      #int_RDA2
      void RDA2_isr(void)
      {
      process = 2;
      }

      #int_TIMER1
      void TIMER1_isr(void)
      {
      process = 3;
      }

      void main()
      {

      setup_adc_ports(NO_ANALOGS|VSS_VDD);
      setup_adc(ADC_OFF);
      setup_psp(PSP_DISABLED);
      setup_spi(SPI_SS_DISABLED);
      setup_wdt(WDT_OFF);
      setup_timer_0(RTCC_INTERNAL);
      setup_timer_1(T1_DISABLED);
      setup_timer_2(T2_DISABLED,0,1);
      setup_timer_4(T4_DISABLED,0,1);
      setup_comparator(NC_NC_NC_NC);
      setup_vref(FALSE);
      //Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
      enable_interrupts(INT_TIMER1);
      enable_interrupts(GLOBAL);

      switch (process) {

      case 0: printf("idle");

      break;

      case 1: printf("process = 1");
      received_req();
      reply_data();
      process = 0;

      break;

      case 2: printf("process = 2");
      received_req();
      reply_data();
      process = 0;

      break;

      default: printf("process = 3");
      received_req();
      reply_data();
      process = 0;

      break; }
      }

      void received_req(void)
      {
      printf("received request from _ ");
      //read
      //save
      }

      char value;
      void reply_data(void)
      {
      printf("reply data to _");
      putc(value); //tx reply
      }

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.