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 support@ccsinfo.com

PIC24HJ256GP610 CAN-BUS problem [solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ck



Joined: 02 May 2012
Posts: 18

View user's profile Send private message

PIC24HJ256GP610 CAN-BUS problem [solved]
PostPosted: Wed May 02, 2012 1:50 am     Reply with quote

Hi,
I have PIC24HJ256GP610 and nothing appeared at CAN-TX pin with this code:
Code:

//
//   Test Firmware PIC24HJ
//
//

#include <24HJ256GP610.h>

#DEVICE ADC=12


#fuses NOWDT   //No Watch Dog Timer
#fuses NOWRTB   //Boot block not write protected
#fuses NOBSS   //No boot segment
#fuses NOPROTECT  //Code Protected form reads
#fuses NOWRT   //Program memory not write protected
#fuses PR_PLL   //Primary Oscillator with PLL
#fuses NOCKSFSM   //Clock Switching disabled
#fuses NOOSCIO   //OSC2 is clock output
#fuses HS      //Primary oscillator HS
#fuses WINDIS   //WD in non-windows mode
#fuses WPRES128
#fuses WPOSTS16
#fuses NOPUT   //No Power on Reset Timer value
#fuses NOIESO   //Internal external switch Over mode disabled
#fuses NORSS   //No secure segment RAM
#fuses NOSSS   //No secure segment
#fuses NOWRTSS   //Secure segment not write protected
#fuses NORBS   //No Boot Ram defined
#fuses NODEBUG   //No debug mode
#fuses NOJTAG   //JTAG DISABLED
#fuses ICSP2   //ICD2 uses pin2

#use delay(clock=80000000)

#define CAN_USE_EXTENDED_ID FALSE
#include <can-PIC24.c>
struct rx_stat rxstat;
int32 rx_id;
int tx_buffer[8];
int rx_buffer[8];
int rx_len;
int tx_leng;

#define ID_EXT 1
#define ID_NORM 0
#define RTC 1
#define DATA_FRAME 0
#define PRIORITY 1

void main(){
        #use fast_io(F)
   set_tris_f(0b0000000010000001);
   output_f(0);
   can_init();
        tx_buffer[0]=0;
   tx_buffer[1]=1;
   tx_buffer[2]=2;
   tx_buffer[3]=3;
   tx_buffer[4]=4;
   tx_buffer[5]=5;
   tx_buffer[6]=6;
   tx_buffer[7]=7;
   tx_leng=8;
        while(TRUE){
      delay_ms(100);
      can_putd(300, &tx_buffer[0],tx_leng, PRIORITY, ID_NORM, DATA_FRAME);   
   }
}




Anybody can help me please?


Last edited by ck on Thu May 03, 2012 2:32 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 02, 2012 1:31 pm     Reply with quote

Do you have a CAN bus driver chip, such as MCP2551, connected to the PIC ?
ck



Joined: 02 May 2012
Posts: 18

View user's profile Send private message

PostPosted: Thu May 03, 2012 2:30 am     Reply with quote

Thanks for reply. Indeed I have transceiver, the SN65HVD232 working at 3.3V (same as PIC24).

Nothing appears because we have to choose the Transmitter Buffer (That isn't set by default and no documentation explain it). So the missing code was:
Code:

can_enable_b_transfer(0);

Also I had problem in Baudrate but I solved it depth looking in Can Control Registers.

My focus is build a CCS PIC24 Can-bus Bootloader and if anybody is interested please contact me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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