We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi , I want to use external interrupts of 89C51 to receive/transmit data using sync modem. Following is the C code i have written but that is not working.I'm using evaluation version of Keil Compiler . I have following doubts about ISR in C 1. Do we need to enable and disable the interrupt in its ISR to prohibit it to interrupt unless its ISR is over. 2. It it necessary to specify the register bank ( using 1 ..... etc ) 3. To set serial port baud rate do we need to set TCON regs , default C51 setting is sufficient or not. 4. Do I need to modify startup.a51 file for this code. Can anybody suggest me any other way to control sync modem ( source code or any url ) ? thaks Sanjay
/*;Program to Transmit data to GMSK CMX469 Modem ;Int0 -> Applied RxSync clock used for data sending P3.2 ;Int1 -> Applied Txsync clock used for data receiving P3.3 ;P1.0 -> Tx data ;P1.1 -> Rx data ;P1.2 -> Carrier Detect */ #include <reg51.h> #include <stdio.h> //void ReceiveData(void); //to be called by interrupt ISR //void TransmitData(void); //to be called by interrupt ISR void InitializeInterrupts(void); void InitSerialPort(void); static void INT0_ISR (void); //RX Sync clock static void INT1_ISR (void); //TX sync clock void main() { InitSerialPort(); InitializeInterrupts(); while(1) { P0=0xff; P2=0xff; } } static void INT1_ISR (void) interrupt 2 using 1 //for tx { EX1=0; //disable int1 P2=0x00; // making it zero to know whether intr has ocured on falling edge // TransmitData(); //function to tranmit data EX1=1; //enable int1 } static void INT0_ISR (void) interrupt 0 using 1 //for receive { EX0=0; //disable int0 P0=0x00; // making it zero to know whether intr has ocured on falling edge //ReceiveData(); //function to receive data EX0=1; //enable int0 } void InitializeInterrupts(void) { EX0=1; IT0=1; //falling edge EX1=1; IT1=1; //falling edge EA=1; } void InitSerialPort(void) { SCON = 0x52; /* SCON */ /* setup serial port control */ TMOD = 0x20; /* TMOD */ /* hardware (9600 BAUD @12MHZ) */ TCON = 0x69; /* TCON */ TH1 = 0xfd; /* TH1 */ //9600 baud rate TR1=1; printf("\nModem Program is running\n"); }
Pls wd u considr rding sum manuls?