Click here to Skip to main content
15,892,059 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
Richard MacCutchan1-Jan-11 21:35
mveRichard MacCutchan1-Jan-11 21:35 
GeneralRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
Richard MacCutchan2-Jan-11 1:18
mveRichard MacCutchan2-Jan-11 1:18 
GeneralRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
jschell2-Jan-11 8:49
jschell2-Jan-11 8:49 
GeneralRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
Richard MacCutchan2-Jan-11 23:29
mveRichard MacCutchan2-Jan-11 23:29 
GeneralRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
Philippe Mori10-Mar-11 15:26
Philippe Mori10-Mar-11 15:26 
AnswerRe: On which OS Architecture i am 32 Bit or 64 Bit, Can c++ tell me? Pin
Karpov Andrey1-Jan-11 6:45
Karpov Andrey1-Jan-11 6:45 
Questionsaveing bindingsource to database (sql) Pin
sam_b15-Dec-10 11:33
sam_b15-Dec-10 11:33 
QuestionIs there anyone have experience in programming Controller Area Network? Pin
kent524414-Dec-10 22:11
kent524414-Dec-10 22:11 
Hi,

I need to program PIC 16F876A to control MCP2515 CAN controller? Anyone got any experience or example to shared? I having trouble in understanding the example code i found.

/*
 * Project name:
     Can_1st (CAN Network demonstration with mikroE's CAN module)
 * Copyright:
     (c) MikroElektronika, 2005-2008
 * Description:
     This project is a simple demonstration of CAN on PIC18F448 with minor
     adjustments, it should work with any other MCU that has a CAN module.
     This code demonstrates how to use CAN library functions and procedures.
     It is used together with the CAN_2nd example (on second MCU), and it can
     be used to test the connection of MCU to the CAN network.
     This node initiates the communication with the Can_2nd node by sending some
     data to its address. The 2nd node responds by sending back the data incre-
     mented by 1. This (1st) node then does the same and sends incremented data
     back to 2nd node, etc.
 * Test configuration:
     MCU:             PIC18F448
     Dev.Board:       EasyPIC6
                      http://www.mikroe.com/en/tools/easypic6/
     Oscillator:      HS, 8.0000 MHz
     Ext. Modules:    mE CAN extra board on PORTB
                      http://www.mikroe.com/en/tools/can1/
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/en/compilers/mikroc/pro/pic/
 * NOTES:
     - Consult the CAN standard about CAN bus termination resistance.
     - Turn off LEDs SW9.2 and pull-up (place jumper in upper position)  (board specific)
       lines on PORTB. mE CAN extra board should be connected to PORTB.
     - Turn on LEDs on PORTC (SW9.3) (board specific)
 */

unsigned char Can_Init_Flags, Can_Send_Flags, Can_Rcv_Flags; // can flags
unsigned char Rx_Data_Len;                                   // received data length in bytes
char RxTx_Data[8];                                           // can rx/tx data buffer
char Msg_Rcvd;                                               // reception flag
const long ID_1st = 12111, ID_2nd = 3;                       // node IDs
long Rx_ID;

void main() {

  PORTC = 0;                                                // clear PORTC
  TRISC = 0;                                                // set PORTC as output

  Can_Init_Flags = 0;                                       //
  Can_Send_Flags = 0;                                       // clear flags
  Can_Rcv_Flags  = 0;                                       //

  Can_Send_Flags = _CAN_TX_PRIORITY_0 &                     // form value to be used
                   _CAN_TX_XTD_FRAME &                      //     with CANWrite
                   _CAN_TX_NO_RTR_FRAME;

  Can_Init_Flags = _CAN_CONFIG_SAMPLE_THRICE &              // form value to be used
                   _CAN_CONFIG_PHSEG2_PRG_ON &              // with CANInit
                   _CAN_CONFIG_XTD_MSG &
                   _CAN_CONFIG_DBL_BUFFER_ON &
                   _CAN_CONFIG_VALID_XTD_MSG;
  
  CANInitialize(1,3,3,3,1,Can_Init_Flags);                  // Initialize CAN module
  CANSetOperationMode(_CAN_MODE_CONFIG,0xFF);               // set CONFIGURATION mode
  CANSetMask(_CAN_MASK_B1,-1,_CAN_CONFIG_XTD_MSG);          // set all mask1 bits to ones
  CANSetMask(_CAN_MASK_B2,-1,_CAN_CONFIG_XTD_MSG);          // set all mask2 bits to ones
  CANSetFilter(_CAN_FILTER_B2_F4,ID_2nd,_CAN_CONFIG_XTD_MSG);// set id of filter B2_F4 to 2nd node ID

  CANSetOperationMode(_CAN_MODE_NORMAL,0xFF);               // set NORMAL mode

  RxTx_Data[0] = 9;                                         // set initial data to be sent

  CANWrite(ID_1st, RxTx_Data, 1, Can_Send_Flags);           // send initial message

  while(1) {                                                               // endless loop
    Msg_Rcvd = CANRead(&Rx_ID , RxTx_Data , &Rx_Data_Len, &Can_Rcv_Flags); // receive message
    if ((Rx_ID == ID_2nd) && Msg_Rcvd) {                                   // if message received check id
      PORTC = RxTx_Data[0];                                                // id correct, output data at PORTC
      RxTx_Data[0]++ ;                                                     // increment received data
      Delay_ms(10);
      CANWrite(ID_1st, RxTx_Data, 1, Can_Send_Flags);                      // send incremented data back
    }
  }
}


/*
 * Project name:
     Can_2nd (CAN Network demonstration with mikroE's CAN module)
 * Copyright:
     (c) MikroElektronika, 2005-2008
 * Description:
     This project is a simple demonstration of CAN on PIC18F448 with minor
     adjustments, it should work with any other MCU that has a CAN module.
     This code demonstrates how to use CAN library functions and procedures.
     It is used together with the Can_1st example (on second MCU), and it can
     be used to test the connection of MCU to the CAN network.
     This node receives data, increments it by 1 and send it back to the 1st node.
 * Test configuration:
     MCU:             PIC18F448
     Dev.Board:       EasyPIC6
                      http://www.mikroe.com/en/tools/easypic6/
     Oscillator:      HS, 8.0000 MHz
     Ext. Modules:    mE CAN extra board on PORTB
                      http://www.mikroe.com/en/tools/can1/
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/en/compilers/mikroc/pro/pic/
 * NOTES:
    - Consult the CAN standard about CAN bus termination resistance.
    - Turn off LEDs SW9.2 and pull-up (place jumper in upper position)  (board specific)
      lines on PORTB. mE CAN extra board should be connected to PORTB.
    - Turn on LEDs on PORTC (SW9.3) (board specific)
 */

unsigned char Can_Init_Flags, Can_Send_Flags, Can_Rcv_Flags; // can flags
unsigned char Rx_Data_Len;                                   // received data length in bytes
char RxTx_Data[8];                                           // can rx/tx data buffer
char Msg_Rcvd;                                               // reception flag
const long ID_1st = 12111, ID_2nd = 3;                       // node IDs
long Rx_ID;

void main() {

  PORTC = 0;                                                // clear PORTC
  TRISC = 0;                                                // set PORTC as output

  Can_Init_Flags = 0;                                       //
  Can_Send_Flags = 0;                                       // clear flags
  Can_Rcv_Flags  = 0;                                       //

  Can_Send_Flags = _CAN_TX_PRIORITY_0 &                     // form value to be used
                   _CAN_TX_XTD_FRAME &                      //     with CANWrite
                   _CAN_TX_NO_RTR_FRAME;

  Can_Init_Flags = _CAN_CONFIG_SAMPLE_THRICE &              // form value to be used
                   _CAN_CONFIG_PHSEG2_PRG_ON &              // with CANInit
                   _CAN_CONFIG_XTD_MSG &
                   _CAN_CONFIG_DBL_BUFFER_ON &
                   _CAN_CONFIG_VALID_XTD_MSG &
                   _CAN_CONFIG_LINE_FILTER_OFF;

  CANInitialize(1,3,3,3,1,Can_Init_Flags);                  // initialize external CAN module
  CANSetOperationMode(_CAN_MODE_CONFIG,0xFF);               // set CONFIGURATION mode
  CANSetMask(_CAN_MASK_B1,-1,_CAN_CONFIG_XTD_MSG);          // set all mask1 bits to ones
  CANSetMask(_CAN_MASK_B2,-1,_CAN_CONFIG_XTD_MSG);          // set all mask2 bits to ones
  CANSetFilter(_CAN_FILTER_B2_F3,ID_1st,_CAN_CONFIG_XTD_MSG);// set id of filter B2_F3 to 1st node ID

  CANSetOperationMode(_CAN_MODE_NORMAL,0xFF);               // set NORMAL mode

  while (1) {                                                              // endless loop
    Msg_Rcvd = CANRead(&Rx_ID , RxTx_Data , &Rx_Data_Len, &Can_Rcv_Flags); // receive message
    if ((Rx_ID == ID_1st) && Msg_Rcvd) {                                   // if message received check id
      PORTC = RxTx_Data[0];                                                // id correct, output data at PORTC
      RxTx_Data[0]++ ;                                                     // increment received data
      CANWrite(ID_2nd, RxTx_Data, 1, Can_Send_Flags);                      // send incremented data back
    }
  }
}

AnswerRe: Is there anyone have experience in programming Controller Area Network? Pin
Luc Pattyn15-Dec-10 1:22
sitebuilderLuc Pattyn15-Dec-10 1:22 
GeneralRe: Is there anyone have experience in programming Controller Area Network? Pin
kent524415-Dec-10 5:54
kent524415-Dec-10 5:54 
GeneralMy last CAN reply in this forum. Pin
Luc Pattyn15-Dec-10 6:08
sitebuilderLuc Pattyn15-Dec-10 6:08 
GeneralRe: My last CAN reply in this forum. Pin
kent524415-Dec-10 6:19
kent524415-Dec-10 6:19 
QuestionRe: My last CAN reply in this forum. Pin
kent52449-Jan-11 21:32
kent52449-Jan-11 21:32 
AnswerRe: My last CAN reply in this forum. Pin
Luc Pattyn10-Jan-11 0:40
sitebuilderLuc Pattyn10-Jan-11 0:40 
GeneralRe: My last CAN reply in this forum. Pin
kent524411-Jan-11 5:40
kent524411-Jan-11 5:40 
GeneralRe: My last CAN reply in this forum. Pin
kent524412-Jan-11 15:03
kent524412-Jan-11 15:03 
GeneralCAN diagram Pin
Luc Pattyn12-Jan-11 15:09
sitebuilderLuc Pattyn12-Jan-11 15:09 
GeneralRe: CAN diagram Pin
kent524412-Jan-11 16:45
kent524412-Jan-11 16:45 
GeneralRe: CAN diagram Pin
Luc Pattyn12-Jan-11 17:21
sitebuilderLuc Pattyn12-Jan-11 17:21 
QuestionHow to convert SAFEARRAY to System::Object Pin
ptr_Electron12-Dec-10 23:19
ptr_Electron12-Dec-10 23:19 
AnswerRe: How to convert SAFEARRAY to System::Object Pin
Radhakrishnan G.14-Dec-10 20:06
Radhakrishnan G.14-Dec-10 20:06 
QuestionHow to use C DLL in C++/CLI Pin
cancerion1-Dec-10 23:32
cancerion1-Dec-10 23:32 
AnswerRe: How to use C DLL in C++/CLI Pin
Luc Pattyn2-Dec-10 1:00
sitebuilderLuc Pattyn2-Dec-10 1:00 
Questionconversion Pin
rajniyadav1a1-Dec-10 19:09
rajniyadav1a1-Dec-10 19:09 
AnswerRe: conversion Pin
Ajay Vijayvargiya1-Dec-10 21:12
Ajay Vijayvargiya1-Dec-10 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.