Home › Forums › C Programming › input output data using rs232
- This topic has 0 replies, 1 voice, and was last updated 17 years, 3 months ago by pathaksujit.
Viewing 0 reply threads
- AuthorPosts
- September 26, 2007 at 10:32 pm #2011pathaksujitParticipant
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596#include "C:Documents and SettingsPC2Desktopmain system amrmeter.h"<br />#include <18F6720.h><br />#use delay(clock=20000000)<br />#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)<br /><br /><br />void received_req(void);<br />void reply_data(void);<br />int process;<br /><br /><br />#int_RDA<br />void RDA_isr(void)<br />{<br />int i;<br />char c;<br />c = getc(); //rx data<br />for (i=0; i!=c; i++)<br />{<br />putc(c);<br />}<br />process = 1;<br />}<br /><br />#int_RDA2<br />void RDA2_isr(void)<br />{<br />process = 2;<br />}<br /><br />#int_TIMER1<br />void TIMER1_isr(void)<br />{<br />process = 3;<br />}<br /><br />void main()<br />{<br /><br />setup_adc_ports(NO_ANALOGS|VSS_VDD);<br />setup_adc(ADC_OFF);<br />setup_psp(PSP_DISABLED);<br />setup_spi(SPI_SS_DISABLED);<br />setup_wdt(WDT_OFF);<br />setup_timer_0(RTCC_INTERNAL);<br />setup_timer_1(T1_DISABLED);<br />setup_timer_2(T2_DISABLED,0,1);<br />setup_timer_4(T4_DISABLED,0,1);<br />setup_comparator(NC_NC_NC_NC);<br />setup_vref(FALSE);<br />//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab<br />enable_interrupts(INT_TIMER1);<br />enable_interrupts(GLOBAL);<br /><br />switch (process) {<br /><br />case 0: printf("idle");<br /><br />break;<br /><br />case 1: printf("process = 1");<br />received_req();<br />reply_data();<br />process = 0;<br /><br />break;<br /><br />case 2: printf("process = 2");<br />received_req();<br />reply_data();<br />process = 0;<br /><br />break;<br /><br />default: printf("process = 3");<br />received_req();<br />reply_data();<br />process = 0;<br /><br />break; }<br />}<br /><br />void received_req(void)<br />{<br />printf("received request from _ ");<br />//read<br />//save<br />}<br /><br />char value;<br />void reply_data(void)<br />{<br />printf("reply data to _");<br />putc(value); //tx reply<br />}<br />
- AuthorPosts
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.