R
raaloottan
Guest
netko ugoditi pomoć.im događaj moje završne godine projekt može.
spojevi su napravljeni kako treba. terminatora iskorišten je 100ohm.
koristiti 2 zajedničke jednu cjedilu pcbwires upletenom kao CAN bus i palili sljedećih kodova u mikroC
i use 8MHz
crystal ocsillator
version8.0.0.0. 8MHz
koristim crystal ocsillator
učinio sam nešto propustio?
.
ugoditi pomoć mene.
zadnji datum je 12. travnja ../ / CODE ZA PRVI NODE
unsigned char data [] = "test";
unsigned short init_flag, send_flag, dt, duž, read_flag;
char SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg;
dugo masku;
unsigned int int_flag, rs_int;
void init_pic ()
(
CMCON = 0x07; / / komparator off
trisb = 1; / / PORTB JE I / P
TRISD = 0; / / port d se o / p
ADCON1 = 0x07; / / ADC OFF
TRISA = 1; / / LUKA JE I / P
PORTA.F4 = 1; / / LED1 OFF
PORTA.F5 = 1; / / LED2 OFF
INTCON.INT0IE = 1; / / INT0 OMOGUĆITI
INTCON2.INTEDG0 = 0; / / EDGE INT0 PADAJU
INTCON3.INT1IE = 1; / / INT1 OMOGUĆITI
INTCON2.INTEDG1 = 0; / / EDGE INT1 PADAJU
RCON.IPEN = 1; / / ENABLE Interrupt PRIORITET
INTCON3.INT1IP = 1; / / int1 visoki prioritet
)
void main ()
(
init_pic ();
Lcd_Init (PORTD &);
Lcd_Cmd (LCD_CLEAR);
Lcd_Out (1,1, "Pokretanje");
Lcd_Out (2,1, "Molimo pričekajte");
Delay_ms (2000);
Lcd_Cmd (LCD_CLEAR);
/ / CAN vrijeme
SJW = 1;
BRP = 1;
Phase_Seg1 = 6;
Phase_Seg2 = 7;
Prop_Seg = 6;
/ / Flags
init_flag = CAN_CONFIG_SAMPLE_THRICE &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_STD_MSG &
CAN_CONFIG_DBL_BUFFER_ON &
CAN_CONFIG_VALID_STD_MSG &
CAN_CONFIG_LINE_FILTER_OFF;
send_flag = CAN_TX_PRIORITY_0 &
CAN_TX_STD_FRAME &
CAN_TX_NO_RTR_FRAME;
read_flag = 0;
/ / CAN pokretanju
CANInitialize (SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg, init_flag);
CANSetOperationMode (CAN_MODE_CONFIG, 0xff);
Lcd_Out (1,1, "način confgured");
Delay_ms (1000);
masku =- 1;
CANSetMask (CAN_MASK_B1, maska, CAN_CONFIG_STD_MSG);
CANSetMask (CAN_MASK_B2, maska, CAN_CONFIG_STD_MSG);
CANSetFilter (CAN_FILTER_B2_F3, 44, CAN_CONFIG_STD_MSG); / / panike id == 44
CANSetOperationMode (CAN_MODE_NORMAL, 0xff);
Lcd_Out (1,1 ", confign učinio");
Delay_ms (1000);
dok je (1)
(
Lcd_Out (1,1 ", dok su iznutra");
Delay_ms (1000);
if (! PORTB.F0)
(
dok je (! INTCON.INT0IF);
Lcd_Cmd (LCD_CLEAR);
CANWrite (22, podataka, 4, send_flag);
Lcd_Out (1,1, "napisao");
Delay_ms (1000);
)
)
)
/ / Kod za čvor 2
unsigned char podataka [4], comp_no [4];
unsigned short init_flag, send_flag, dt, duž, read_flag;
char SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg;
id dugo, maska;
unsigned int int_flag, rs_int;
void init_pic ()
(
TRISB.F3 = 1;
trisb.f2 = 0;
trisb.f0 = 1;
trisb.f1 = 1;
CMCON = 0x07; / / komparator off
TRISD = 0; / / port d se o / p
ADCON1 = 0x07; / / ADC OFF
TRISA = 1; / / LUKA JE I / P
PORTA.F4 = 1; / / LED1 OFF
PORTA.F5 = 1; / / LED2 OFF
INTCON.INT0IE = 1; / / INT0 OMOGUĆITI
INTCON2.INTEDG0 = 0; / / EDGE INT0 PADAJU
INTCON3.INT1IE = 1; / / INT1 OMOGUĆITI
INTCON2.INTEDG1 = 0; / / EDGE INT1 PADAJU
RCON.IPEN = 1; / / ENABLE Interrupt PRIORITET
INTCON3.INT1IP = 1; / / int1 visoki prioritet
)void main ()
(
init_pic ();
Lcd_Init (PORTD &);
Lcd_Cmd (LCD_CLEAR);
Lcd_Out (1,1, "Pokretanje");
Lcd_Out (2,1, "Molimo pričekajte");
Delay_ms (2000);
Lcd_Cmd (LCD_CLEAR);
/ / CAN vrijeme
SJW = 1;
BRP = 1;
Phase_Seg1 = 6;
Phase_Seg2 = 7;
Prop_Seg = 6;
/ / Flags
init_flag = CAN_CONFIG_SAMPLE_THRICE &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_STD_MSG &
CAN_CONFIG_DBL_BUFFER_ON &
CAN_CONFIG_VALID_STD_MSG &
CAN_CONFIG_LINE_FILTER_OFF;
send_flag = CAN_TX_PRIORITY_0 &
CAN_TX_STD_FRAME &
CAN_TX_NO_RTR_FRAME;
read_flag = 0;
/ / CAN pokretanju
CANInitialize (SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg, init_flag);
CANSetOperationMode (CAN_MODE_CONFIG, 0xff);
masku =- 1;
Lcd_Out (1,1, "način konfiguriran");
Delay_ms (2000);
CANSetMask (CAN_MASK_B1, maska, CAN_CONFIG_STD_MSG);
CANSetMask (CAN_MASK_B2, maska, CAN_CONFIG_STD_MSG);
CANSetFilter (CAN_FILTER_B2_F3, 22, CAN_CONFIG_STD_MSG);
CANSetOperationMode (CAN_MODE_NORMAL, 0xff);
Lcd_Out (1,1, "operacija učinio");
Delay_ms (1000);
dok je (1)
(
Lcd_Out (1,1 ", dok su iznutra");
Delay_ms (1000);
dt = 0;
dt = CANRead (& id, podataka, & len, & read_flag);
Lcd_Cmd (LCD_CLEAR); / / Clear display
Lcd_Out (1,1, "čitati");
Delay_ms (1000);
dok je (! DT);
ako (DT == 1 & & id == 22)
(
Lcd_Out (1,1, "dobili");
Delay_ms (1000);
strcpy (comp_no, data);
Lcd_Out (2,11, comp_no);
Delay_ms (2000);
)
)
)
spojevi su napravljeni kako treba. terminatora iskorišten je 100ohm.
koristiti 2 zajedničke jednu cjedilu pcbwires upletenom kao CAN bus i palili sljedećih kodova u mikroC
i use 8MHz
crystal ocsillator
version8.0.0.0. 8MHz
koristim crystal ocsillator
učinio sam nešto propustio?
.
ugoditi pomoć mene.
zadnji datum je 12. travnja ../ / CODE ZA PRVI NODE
unsigned char data [] = "test";
unsigned short init_flag, send_flag, dt, duž, read_flag;
char SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg;
dugo masku;
unsigned int int_flag, rs_int;
void init_pic ()
(
CMCON = 0x07; / / komparator off
trisb = 1; / / PORTB JE I / P
TRISD = 0; / / port d se o / p
ADCON1 = 0x07; / / ADC OFF
TRISA = 1; / / LUKA JE I / P
PORTA.F4 = 1; / / LED1 OFF
PORTA.F5 = 1; / / LED2 OFF
INTCON.INT0IE = 1; / / INT0 OMOGUĆITI
INTCON2.INTEDG0 = 0; / / EDGE INT0 PADAJU
INTCON3.INT1IE = 1; / / INT1 OMOGUĆITI
INTCON2.INTEDG1 = 0; / / EDGE INT1 PADAJU
RCON.IPEN = 1; / / ENABLE Interrupt PRIORITET
INTCON3.INT1IP = 1; / / int1 visoki prioritet
)
void main ()
(
init_pic ();
Lcd_Init (PORTD &);
Lcd_Cmd (LCD_CLEAR);
Lcd_Out (1,1, "Pokretanje");
Lcd_Out (2,1, "Molimo pričekajte");
Delay_ms (2000);
Lcd_Cmd (LCD_CLEAR);
/ / CAN vrijeme
SJW = 1;
BRP = 1;
Phase_Seg1 = 6;
Phase_Seg2 = 7;
Prop_Seg = 6;
/ / Flags
init_flag = CAN_CONFIG_SAMPLE_THRICE &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_STD_MSG &
CAN_CONFIG_DBL_BUFFER_ON &
CAN_CONFIG_VALID_STD_MSG &
CAN_CONFIG_LINE_FILTER_OFF;
send_flag = CAN_TX_PRIORITY_0 &
CAN_TX_STD_FRAME &
CAN_TX_NO_RTR_FRAME;
read_flag = 0;
/ / CAN pokretanju
CANInitialize (SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg, init_flag);
CANSetOperationMode (CAN_MODE_CONFIG, 0xff);
Lcd_Out (1,1, "način confgured");
Delay_ms (1000);
masku =- 1;
CANSetMask (CAN_MASK_B1, maska, CAN_CONFIG_STD_MSG);
CANSetMask (CAN_MASK_B2, maska, CAN_CONFIG_STD_MSG);
CANSetFilter (CAN_FILTER_B2_F3, 44, CAN_CONFIG_STD_MSG); / / panike id == 44
CANSetOperationMode (CAN_MODE_NORMAL, 0xff);
Lcd_Out (1,1 ", confign učinio");
Delay_ms (1000);
dok je (1)
(
Lcd_Out (1,1 ", dok su iznutra");
Delay_ms (1000);
if (! PORTB.F0)
(
dok je (! INTCON.INT0IF);
Lcd_Cmd (LCD_CLEAR);
CANWrite (22, podataka, 4, send_flag);
Lcd_Out (1,1, "napisao");
Delay_ms (1000);
)
)
)
/ / Kod za čvor 2
unsigned char podataka [4], comp_no [4];
unsigned short init_flag, send_flag, dt, duž, read_flag;
char SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg;
id dugo, maska;
unsigned int int_flag, rs_int;
void init_pic ()
(
TRISB.F3 = 1;
trisb.f2 = 0;
trisb.f0 = 1;
trisb.f1 = 1;
CMCON = 0x07; / / komparator off
TRISD = 0; / / port d se o / p
ADCON1 = 0x07; / / ADC OFF
TRISA = 1; / / LUKA JE I / P
PORTA.F4 = 1; / / LED1 OFF
PORTA.F5 = 1; / / LED2 OFF
INTCON.INT0IE = 1; / / INT0 OMOGUĆITI
INTCON2.INTEDG0 = 0; / / EDGE INT0 PADAJU
INTCON3.INT1IE = 1; / / INT1 OMOGUĆITI
INTCON2.INTEDG1 = 0; / / EDGE INT1 PADAJU
RCON.IPEN = 1; / / ENABLE Interrupt PRIORITET
INTCON3.INT1IP = 1; / / int1 visoki prioritet
)void main ()
(
init_pic ();
Lcd_Init (PORTD &);
Lcd_Cmd (LCD_CLEAR);
Lcd_Out (1,1, "Pokretanje");
Lcd_Out (2,1, "Molimo pričekajte");
Delay_ms (2000);
Lcd_Cmd (LCD_CLEAR);
/ / CAN vrijeme
SJW = 1;
BRP = 1;
Phase_Seg1 = 6;
Phase_Seg2 = 7;
Prop_Seg = 6;
/ / Flags
init_flag = CAN_CONFIG_SAMPLE_THRICE &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_STD_MSG &
CAN_CONFIG_DBL_BUFFER_ON &
CAN_CONFIG_VALID_STD_MSG &
CAN_CONFIG_LINE_FILTER_OFF;
send_flag = CAN_TX_PRIORITY_0 &
CAN_TX_STD_FRAME &
CAN_TX_NO_RTR_FRAME;
read_flag = 0;
/ / CAN pokretanju
CANInitialize (SJW, BRP, Phase_Seg1, Phase_Seg2, Prop_Seg, init_flag);
CANSetOperationMode (CAN_MODE_CONFIG, 0xff);
masku =- 1;
Lcd_Out (1,1, "način konfiguriran");
Delay_ms (2000);
CANSetMask (CAN_MASK_B1, maska, CAN_CONFIG_STD_MSG);
CANSetMask (CAN_MASK_B2, maska, CAN_CONFIG_STD_MSG);
CANSetFilter (CAN_FILTER_B2_F3, 22, CAN_CONFIG_STD_MSG);
CANSetOperationMode (CAN_MODE_NORMAL, 0xff);
Lcd_Out (1,1, "operacija učinio");
Delay_ms (1000);
dok je (1)
(
Lcd_Out (1,1 ", dok su iznutra");
Delay_ms (1000);
dt = 0;
dt = CANRead (& id, podataka, & len, & read_flag);
Lcd_Cmd (LCD_CLEAR); / / Clear display
Lcd_Out (1,1, "čitati");
Delay_ms (1000);
dok je (! DT);
ako (DT == 1 & & id == 22)
(
Lcd_Out (1,1, "dobili");
Delay_ms (1000);
strcpy (comp_no, data);
Lcd_Out (2,11, comp_no);
Delay_ms (2000);
)
)
)