CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Same problem continues with CAN bus [Solved]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

Same problem continues with CAN bus [Solved]
PostPosted: Sat Jun 26, 2021 4:11 am     Reply with quote

My friend
Thanks for answering to me.

I change schematic to two 18f25k80 and can-18xxx8.c drivers.
did not communicate.

I will be mad.please Help me.
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 4:52 am     Reply with quote

Are you using real PICs? If so whose PCB or modules are they ?
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 5:03 am     Reply with quote

They appear to be continuing an earlier post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=55707

They should go back and continue that thread instead of starting a new one.
_________________
Google and Forum Search are some of your best tools!!!!
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

Sure
PostPosted: Sat Jun 26, 2021 9:38 am     Reply with quote

temtronic wrote:
Are you using real PICs? If so whose PCB or modules are they ?


I prepare Mikroc project to check canbus that is okay.
I prepare Arduino Uno project that is also okay.

I changed to with can-18f4580.c with pic18f25k80 chips too.

But I have Easypic7 and Easypic5 to put there 2 PIC18f25k80 and mcp2551 for to breadboard. Boards are okay too.

I load programs to chips with easypic7 and runs so
no communications.

Seems to send data to another and other side do not get anything.
I am ccs programmer also.
I can send programs to here if you want.
sincerely


Last edited by amcasi on Sat Jun 26, 2021 10:00 am; edited 2 times in total
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 9:47 am     Reply with quote

dyeatman wrote:
They appear to be continuing an earlier post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=55707

They should go back and continue that thread instead of starting a new one.


My friend
No I am not using development card.
I will peparing new card for with canbus and max bus.
I am checking can protocol to write to card for industrial welding project.
İf I can communicate with chips will be fine for us.

Sincerely
Regular Guy



Joined: 04 Jun 2017
Posts: 110

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 11:13 am     Reply with quote

Hi Amcasi

Sent you a PM.
_________________
PIC Hobbyist
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 11:58 am     Reply with quote

Regular Guy wrote:
Hi Amcasi

Sent you a PM.


Thank you
I have U64 and development kit for pic18f452 board.

What are we goig to do with these?

thanks


Last edited by amcasi on Sat Jun 26, 2021 3:24 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Sure
PostPosted: Sat Jun 26, 2021 12:33 pm     Reply with quote

amcasi wrote:
I prepare Mikroc project to check canbus that is okay.
That works so you think your hardware is OK. So the CCS software
or your use of it, must be the problem

amcasi wrote:
load programs to chips with easypic7 and runs so
no communications.
You can program both PICs OK.

amcasi wrote:
I changed to with can-18f4580.c with pic18f25k80 chips too.
Seems to send data to another and other side do not get anything.
Post a small test program for each board that shows the problem.
Make them be small but complete. Post lines for #include, #fuses,
#use delay() and the programs.
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 3:17 pm     Reply with quote

Thanks to PCM programmer for answering me and All.
Here my code 1:
Code:
//    can25K80_1.c
//
//
#include <18f25k80.h>
#device ADC=8  *=16 //ICD=TRUE
#fuses intrc_io,NOWDT,BROWNOUT,PUT,NOPLLEN,SOSC_DIG,NOIESO,NOFCMEN,CANB
#use delay(internal=16mhz)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7,ERRORS)

#define BTN  PIN_c2

#define LED1 PIN_c3
#define LED2 PIN_c4
#define LED3 PIN_c5
#define LED4 PIN_c1

#define CAN_TX_PIN    PIN_B2
#define CAN_RX_PIN    PIN_B3


#define CAN_BRG_PRESCALAR        15
#define CAN_BRG_PHASE_SEGMENT_1  6
#define CAN_BRG_PHASE_SEGMENT_2  6
#define CAN_BRG_PROPAGATION_TIME 0
#define CAN_BRG_SYNCH_JUMP_WIDTH 0

#include <can-18f4580.c>
//#include <can__18xxx8.c>

int16 ms,tms=0;

struct rx_stat rxstat;
int32 rx_idn;
int8 in_data[8];
int8 rx_len=8;

int8  i;

//send a request (tx_rtr=1) for 8 bytes of data (tx_len=8) from id 24 (tx_id=24)
int out_data[8];

int tx_len=8;
int tx_pri=3;
int1 tx_ext=1;
int1 tx_rtr=0;


#define ID1 0x200
#define ID2 0x300

#int_timer0
void isr_timer0(void) {
   ms++;
   if (tms++ > 15){

      tms=0;
   }
   output_toggle(PIN_A2);
}
/////////////////////////////////
void clr_Buf() {
   // CLEAR TX AND RX BUFFERS
   
//!      out_data[0]=0;
//!      out_data[1]=0;
      out_data[2]=0;
      out_data[3]=0;
      out_data[4]=0;
      out_data[5]=0;
      out_data[6]=0;
      out_data[7]=0;

}
/////////////////////////////////
void fill_Buf() {
   // fill RX BUFFERS
//!      out_data[0]="0";
//!      out_data[1]="1";
      out_data[2]='4';
      out_data[3]='3';
      out_data[4]='7';
      out_data[5]='6';
      out_data[6]='3';
      out_data[7]='2';
}
void main() {
   delay_ms(200);
   output_a(0x01);
   output_b(0x00);
   output_c(0b00000100);
   
   set_tris_a(0x01);
   set_tris_B(0b00001000);
   set_tris_C(0b00000100);

   setup_timer_0 (T0_INTERNAL|T0_DIV_256|T0_8_BIT);
   set_timer0(178);
   enable_interrupts(int_TIMER0);
   enable_interrupts(GLOBAL);

   can_init();
   i=0;
   clr_Buf();

   //fill_buf();
   can_putd(ID2,&out_data,tx_len,tx_pri,tx_ext,tx_rtr);
   while(TRUE){
      if (!input(BTN)){
          strcpy(&out_data[0], 1);
          strcpy(&out_data[1], 0);
          output_high(LED4);
          output_low(LED3);
          printf("LED3 OFF \r\n");
          printf("LED4 ON \r\n");
      } else  {
          strcpy(&out_data[0], 0);
          strcpy(&out_data[1], 1);
          output_high(LED4);
          output_low(LED4);
          printf("LED3 ON \r\n");         
          printf("LED4 OFF \r\n");
      }
      // gönderme
      if ( can_tbe() && ms > 5)  {
         ms=0;
         fill_buf();
         if (can_putd(ID2, &out_data,tx_len,tx_pri,tx_ext,tx_rtr)) { //success, a transmit buffer was open
            printf("\r\nPUT %U: ID=0x%LX LEN=%UByte ", i, ID2, tx_len);
            printf("PRI=%U EXT=%U RTR=%U   DATA = ", tx_pri, tx_ext, tx_rtr);
            for (i=0;i<tx_len;i++) {
               printf("%X ",&out_data[i]);
            }
            printf("\r\n");
         } else {  printf("Gonderemedim iste\r\n");
         }
      } else printf("Gonderme hazir degil\r\n");
 ////////////////////////////////////////////////////////

      if (can_kbhit()){
         if(can_getd(rx_idn,&in_data,rx_len,rxstat)){
            if(rx_idn == ID1){
               if (bit_test(in_data[0],0) == 1){
                  output_high(LED1);
                  printf("LED1 ON \r\n");
               } else
               if (bit_test(in_data[0],0) == 0){
                  output_low(LED1);
                  printf("LED1 OFF \r\n");
               } else
               if (bit_test(in_data[1],0) ==1){
                  output_high(LED2);
                  printf("LED2 ON \r\n");
               } else
               if (bit_test(in_data[1],0) == 0){
                  output_low(LED2);
                  printf("LED2 OFF \r\n");
               } else printf("Giris gelmiyor.\r\n");
            }else printf("RXID gelmiyor.\r\n");
         }else printf("\r\nAlma fail oldu\r\n");
      }else printf("Data Hazir degil.\r\n");
      delay_ms(500);
   }
}

and second code is:
Code:

//    can25K80_2.c
//
//
#include <18f25k80.h>
#device ADC=8  *=16 //ICD=TRUE
#fuses INTRC_IO,NOWDT,BROWNOUT,PUT,NOPLLEN,SOSC_DIG,NOIESO,NOFCMEN,CANB
#use delay(iNTERNAL=16mhz)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7,ERRORS)

#define BTN  PIN_c2

#define LED1 PIN_c3
#define LED2 PIN_c4
#define LED3 PIN_c5
#define LED4 PIN_c1

#define CAN_TX_PIN    PIN_B2
#define CAN_RX_PIN    PIN_B3

#define CAN_BRG_PRESCALAR        15
#define CAN_BRG_PHASE_SEGMENT_1  6
#define CAN_BRG_PHASE_SEGMENT_2  6
#define CAN_BRG_PROPAGATION_TIME 0
#define CAN_BRG_SYNCH_JUMP_WIDTH 0

#include <can-18f4580.c>
//#include <can-18xxx8.c>

int16 ms,tms=0;
int8 x;

struct rx_stat rxstat;
int32 rx_idn;
int8 in_data[8];
int8 rx_len=8;

int8  i;

//send a request (tx_rtr=1) for 8 bytes of data (tx_len=8) from id 24 (tx_id=24)
int out_data[8];
int32 tx_id=0x200;
int tx_len=8;
int tx_pri=3;
int1 tx_ext=1;
int1 tx_rtr=0;

#define RX_ID  0x200
#define ID1 0x200
#define ID2 0x300

#int_timer0
void isr_timer0(void) {
   set_timer0(178);
   ms++;
   if (tms++ > 5){
      tms=0;
   }
   output_toggle(PIN_A2);
}
/////////////////////////////////
void clr_Buf() {
   // CLEAR TX AND RX BUFFERS
   
      out_data[0]=0;
      out_data[1]=0;
      out_data[2]=0;
      out_data[3]=0;
      out_data[4]=0;
      out_data[5]=0;
      out_data[6]=0;
      out_data[7]=0;

}
/////////////////////////////////
void fill_Buf() {
   // fill RX BUFFERS
//!      out_data[0]="0";
//!      out_data[1]="1";
      out_data[2]='7';
      out_data[3]='6';
      out_data[4]='5';
      out_data[5]='4';
      out_data[6]='3';
      out_data[7]='2';
}
void main() {
   delay_ms(200);
   output_a(0x01);
   output_b(0x00);
   output_c(0b00000100);
   
   set_tris_a(0x01);
   set_tris_B(0b00001000);
   set_tris_C(0b00000100);

   setup_timer_0 (T0_INTERNAL|T0_DIV_256|T0_8_BIT);
   set_timer0(178);
   enable_interrupts(int_TIMER0);
   enable_interrupts(GLOBAL);

   can_init();
   i=0;
   clr_Buf();

   //fill_buf();
   can_putd(ID1,&out_data,tx_len,tx_pri,tx_ext,tx_rtr);
   while(TRUE){
 
      if (!input(BTN)){
          strcpy(out_data[0], 1);
          strcpy(out_data[1], 0);
          output_high(LED4);
          printf("LED4 ON \r\n");
          printf("LED3 OFF \r\n");

      } else  {
          strcpy(out_data[0], 0);
          strcpy(out_data[1], 1);
          output_low(LED4);
          printf("LED4 OFF \r\n");
          printf("LED3 ON \r\n");
      }

      // gönderme

      if ( can_tbe() && ms > 10)  {
         ms=0;
         fill_buf();
         if (can_putd(ID1, &out_data, tx_len,tx_pri,tx_ext,tx_rtr)) { //success, a transmit buffer was open
            printf("\r\nPUT %U: ID=0x%LX LEN=%UByte ", i, ID1, tx_len);
            printf("PRI=%U EXT=%U RTR=%U   DATA = ", tx_pri, tx_ext, tx_rtr);
            for (i=0;i<tx_len;i++) {
               printf("%X ",&out_data[i]);
            }
            printf("\r\n");
         } else { 
            printf("Gonderemedim iste\r\n");
         }
      } else printf("Gonderme hazir degil\r\n");
 //////////////////////////////////////////////////
   
      if (can_kbhit()){
         if(can_getd(rx_idn,&in_data,rx_len,rxstat)){
            if(rx_idn == ID2){
               if (bit_test(in_data[0],0) == 1){
                  output_high(LED1);
                  printf("LED1 ON \r\n");
               } else
               if (bit_test(in_data[0],0) == 0){
                  output_low(LED1);
                  printf("LED1 OFF \r\n");
               } else
               if (bit_test(in_data[1],0) ==1){
                  output_high(LED2);
                  printf("LED2 ON \r\n");
               } else
               if (bit_test(in_data[1],0) == 0){
                  output_low(LED2);
                  printf("LED2 OFF \r\n");
               } else printf("Giris gelmiyor.\r\n");
            }else printf("RXID gelmiyor.\r\n");
         }else printf("\r\nAlma fail oldu\r\n");
      }else printf("Data Hazir degil.\r\n");
      delay_ms(500);
   }
}
thanks so
Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 26, 2021 5:45 pm     Reply with quote

What is your CCS compiler version ? I want to compile your code with
the same version.
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sun Jun 27, 2021 1:37 am     Reply with quote

ok my friend

my ccs compiler version is 5.093
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jun 27, 2021 6:35 am     Reply with quote

hmm...
Quote:
output_a(0x01);
output_b(0x00);
output_c(0b00000100);

set_tris_a(0x01);
set_tris_B(0b00001000);
set_tris_C(0b00000100);

You really should put comments at the end of most lines of code....
I can't understand why you set those outputs, or use 'tris'.

You should also specifically disable any internal peripherals you're not using. It could be a 'default' attachment is causing some 'issue'.
While it's probably not the reason why it doesn't work, always best to be sure.

you've got a 'BTN' ( button, ie a switch)... have you got ANY signal conditioning on that pin ? You need 'debouncing'... usually a small cap(.15) to gnd can work, otherwise you'll see several '1-0-1' transitions when the switch is pressed.
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sun Jun 27, 2021 7:44 am     Reply with quote

My friend

There is no communications. When i press button nothing to changed. Problem is this - I am not sending any data. Looking to scope there is no change. Sending same values. not for my values.
Sincerely
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

PostPosted: Sun Jun 27, 2021 9:17 am     Reply with quote

I replaced mcp2551 with new one also.

Please somebody says something to do this. What i am wrong?
I checked times to times. i can not find any problem.
it is maybe communication. is there any reason to check connect?
any idea please.
Regular Guy



Joined: 04 Jun 2017
Posts: 110

View user's profile Send private message

PostPosted: Sun Jun 27, 2021 10:35 am     Reply with quote

Hi

1 Have you gotten the compiler and the PIC to work first?

Have you blinked an LED to test the 'Development Environment'?

If you do that then you can add code SLOWLY and compile and test each

step of the way.

We are just dealing with one thing at a time here.
_________________
PIC Hobbyist
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group