muratmaman
Joined: 30 Jan 2010 Posts: 19
|
Communicate 2 pic via serial port |
Posted: Wed Oct 20, 2010 4:33 am |
|
|
Dear All,
I would want to send data to another pic by serial port. My board have several peripheral that listening them. When I want to send data another pic I am able to, however in this case I can not listen to another peripheral.
On the contrary, when I want to use peripheral in this case I can not send data to another pic.
My aim is to listen to peripheral and send and receive data to another pic.
My pic 16f886 and compiler
PCH Compiler Version 4.068
Code: |
#include "16f886.h"
#device *=16 ADC=10
#fuses INTRC_IO,NOWDT,NOPROTECT,NOPUT,NOLVP,NOFCMEN,NOMCLR, BROWNOUT // with internal oscillator
#use delay(clock=4000000)
#use rs232(baud=9600,uart1, parity=N, xmit=PIN_C6,rcv=PIN_C7, bits=8, errors, timeout=500, STREAM=ENCODER)
#byte PIE1 = 0x8c
#byte INTCON = 0x8b
void main()
{
short bResult;
disable_interrupts(GLOBAL);
output_a(0b00000000); // motor pinleri A2 ve A3 1 olacak
output_b(0b00000001); // RB0(CRD_CON), RB4(ortak uç), RB5(switch), RB6(Manuel kilit), RB7(Kapı açık kapalı)
output_c(0b10011011); // RC7 (RX input), RC6 (TX output), RC3(SCL), RC4(SDA), RC5(motor pin output ), RC2 Buzzer, RCO ve RC1 saat içininput
output_e(0x00);
set_tris_a(0b00000000);
set_tris_b(0b00000001); // RB0(CRD_CON), RB4(ortak uç), RB5(switch), RB6(Manuel kilit), RB7(Kapı açık kapalı), RC2 Buzzer,
set_tris_c(0b10011011); // RC7 (RX input), RC6 (TX output), RC3(SCL), RC4(SDA), RC5(motor pin output ), RCO ve RC1 saat içininput
set_tris_e(0x00);
port_b_pullups(TRUE);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports( sAN0|VSS_VDD );
set_adc_channel(1);
setup_spi(FALSE);
setup_timer_1(T1_EXTERNAL|T1_CLK_OUT|T1_DIV_BY_1); // setup interrupts
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_oscillator(osc_4mhz);
last_port_b = input_b();
bNotSleep = 1;
// Enable interrupts
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RB);
enable_interrupts(INT_RDA);
enable_interrupts(INT_EXT);
//enable_interrupts(GLOBAL);
SET_TIMER1(0);
// My problem is here. When i was doing is enable i can sedn data to another pic
// however when i was enabling it, i can listen my peripheral but can not able to send data to another pic.
PIE1 = 0x30; // just enable receive and transmit peripheral unit.
INTCON = 0xC0;
|
What can be source of problem ? _________________ I have been developing pic and other microcontroller. I would want to share and get experiment form this site |
|