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

CCS CANBus Dev board problems

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



Joined: 15 Sep 2003
Posts: 75

View user's profile Send private message

CCS CANBus Dev board problems
PostPosted: Thu Dec 28, 2006 4:16 pm     Reply with quote

I'm having 2 problems on this board. Any comments would be appreciated. Thanks.

1. In section 7, I can get the 7-segment to display 0 to 9 in turn with no problems, but cannot get the decimal point to light up for the 7-segment display. Here is the code:

Code:

#include <18F4580.h>
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay(clock=20000000)
#include <can-18xxx8.c>

#define WRITE_REGISTER_D_ID  0x400  // Address of Node D.

// This program turns ON the decimal point in the 7 segment display on Node D.

void write_7_segment(int value) {
    const int lcd_seg[10]={0x40,0x79,0x24,0x30,0x19,
                           0x12,0x02,0x78,0x00,0x10};
    int buffer[3];

    buffer[0]=0x1E;      //addr of gplat = (0x1C + 0x02) where 0x1C is an offset address in MCP25050.
    buffer[1]=0x80;      //mask, Allow GP7 (decimal point) on MCP25050 to be changed.
    buffer[2]=0x00;      //Enable decimal point by setting bit 7 to logic 0.

    // Write to 0x400 (Node D), with buffer of 3 bytes, priority=1, 29bitID, and data frame
    can_putd(WRITE_REGISTER_D_ID, buffer, 3, 1, TRUE, FALSE);
}

void main()
{
   int i=0;

   can_init();

   can_putd(0x100,0,0,1,TRUE,FALSE);  //send an on-bus message to wake up mcp250x0's
   delay_ms(1000);                    //wait for node c to power-up

   while(TRUE) {
       write_7_segment(i);
       delay_ms(1000);
       if(++i==10)
          i=0;
   }
}


I have isolated the MCP25050 from the 7-segment chip, and found that all the LED segments were working including the decimal point (DP) by performing the diode test in both directions. However, with the above program running, the voltage on GP7 (pin 11 of MCP25050) which is connected to the cathode of the DP via a 120R resistor was about 3.7V. Ideally, this should be about 0V to turn on the DP.

Has anyone got the DP to work, or is there a problem on the MCP25050?

2. In section 18, I cannot get the auto-RTR to work. Here is the code:

Node A:
Code:

#include <18F4580.h>
//#device ICD=TRUE
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <can-18F4580.c>

void main()
{
   int32 rx_id;
   int rx_len, i;
   struct rx_stat stat;
   int data[8]={15,14,13,12,11,10,9,8};
   int receive[8];

   can_init();

   can_set_functional_mode(1);

   can_enable_b_transfer(B1);

   can_disable_filter(0xFFFF);
   can_enable_filter(0x01);

   can_set_id(RX0MASK,0xFF00,TRUE);
   can_set_id(RXFILTER0,0x500,TRUE);
   can_set_id(B1ID,0x500,TRUE);

   can_associate_filter_to_mask(ACCEPTANCE_MASK_0,F0BP);
   can_associate_filter_to_buffer(AB1,F0BP);

   can_load_rtr(B1,data,8);
   can_enable_rtr(B1);

   while(TRUE);
}


Node B:
Code:

#include <16F876A.h>
//#device ICD=TRUE
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay(clock=2500000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <can-mcp2510.c>

void main()
{
   int32 rx_id=0;
   int rx_len=0, i;
   struct rx_stat stat;
   int data[8]={7,6,5,4,3,2,1,0};
   int receive[8]={0,0,0,0,0,0,0,0};

   can_init();

   while(TRUE)
   {
      can_putd(0x500,data,8,3,TRUE,TRUE);
      delay_ms(1000);

      if ( can_kbhit() )
      {
          can_getd(rx_id, receive, rx_len, stat);
          printf("Data received!\n\r");
          for(i=0; i<8; i++)
             printf("%i ",receive[i]);

          printf("\n\r%Lx\n\r",rx_id);
      }
      else
      {
          printf("Data not received.\n\r");
      }
   }
}


All I got from Node B was the following:

Data received!
0 0 0 0 0 0 0 0
00000500

and repeats...

The 'receive' buffer is all 0's, and rx_len is also 0. The can_kbhit() function returned a 1. The ID received is correct at 0x500.

Ideally, it should be the following (according to the exercise book):
Data received!
15 14 13 12 11 10 9 8
00000500

and repeats...
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