Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - tr111

Pages: 1 [2] 3
16
   I have know the work in loopback mode,this is FlexCAN performs an internal loop
back that can be used for self test operation.
   But how can I get the data from I send!
   I don't know that
    Receiving CAN data messages
When a CAN data message is received it is placed in a free receive buffer and the owner task is notified of the fact via an interrupt event. It can then pick up the data by calling the generic fnRead(). It is not necessary to specify the read length since data should be read as a block from a single buffer, however there are a number of options available.
......   case INTERRUPT_EVENT:     // on an interrupt event
            switch (ucInputMessage[MSG_INTERRUPT_EVENT]) {
            case CAN_RX_MSG::      // A CAN rx. message is waiting
                Length = fnRead(CAN_interface_ID, ucInputMessage,
                         (0 | GET_CAN_RX_TIME_STAMP | GET_CAN_RX_ID));
                          // collect the message along with some details
                break; ......
Can that more detail, tell me how to do in utasker?????????
the freecale give me some code:
this the interrupt

 MCF_GPIO_PASPAR=MCF_GPIO_PASPAR_SYNCA_CANRX|MCF_GPIO_PASPAR_SYNCB_CANTX;
                         
                         
   
   /* FlexCAN Soft Reset */
   MCF_FlexCAN_CANMCR = MCF_FlexCAN_CANMCR_SOFTRST;
   while ((MCF_FlexCAN_CANMCR & MCF_FlexCAN_CANMCR_SOFTRST) != 0x0) {}
   
   /* initialize FlexCANs */         
   init_flexcan();
   
   /* initialize FlexCAN interrupts */
   init_flexcan_interrupts();
   
   /* zero message in receive buffer 1 */
   * (vuint32 *) (FLEXCAN_BUFFERS + 0x18) = 0x00000000;
   * (vuint32 *) (FLEXCAN_BUFFERS + 0x1C) = 0x00000000;
   
   printf("DONE\n\r");
   
      printf("Received buffer before sending: 0x%08x 0x%08x\n\r", * (vuint32 *) (FLEXCAN_BUFFERS + 0x18), * (vuint32 *) (FLEXCAN_BUFFERS + 0x1C));   
   
   
   /* transmit a message from transmit buffer 0 */   
   * (vuint32 *) (FLEXCAN_BUFFERS + 0x8) = 0xABCD0022;
   * (vuint32 *) (FLEXCAN_BUFFERS + 0xC) = 0xBABA1234;      
   
   MCF_FlexCAN_CANMCR &= ~(MCF_FlexCAN_CANMCR_HALT); //leave HALT
   
   /* await for synchronisation */
   for (i=1;i<255;i++) {}   
   
   //from some reason, this didn't work in loopback mode   
   //while (MCF_CAN_CANMCR0 & MCF_CAN_CANMCR_NOTRDY == MCF_CAN_CANMCR_NOTRDY) {}
      
   * (vuint16 *) FLEXCAN_BUFFERS = 0x0C08; //write CODE for transmission of 8 bytes   

/*********************************************************************************************/
__declspec(interrupt)
void Rx_Buffer1(void)
{
   /* display received data */
   printf("Received data after sending: 0x%08x 0x%08x\n\r", * (vuint32 *) (FLEXCAN_BUFFERS + 0x18), * (vuint32 *) (FLEXCAN_BUFFERS + 0x1C));   
   
   MCF_FlexCAN_IFLAG|=  MCF_FlexCAN_IFLAG_BUF1I;
}


17
NXPTM M522XX, KINETIS and i.MX RT / also the 52235evb'CAN send data!
« on: November 22, 2007, 09:11:56 AM »
static void fnConfigCAN_BUS(void)
{
CANTABLE tCANParameters; // table for passing information to driver
tCANParameters.Task_to_wake = OWN_TASK; // wake us on buffer events
tCANParameters.Channel = 0;        // first hardware interface       
 tCANParameters.ulSpeed = 100000;    // 100K speed
tCANParameters.ulTxID = 0x80;       // default ID of destination                           
tCANParameters.ulRxID = (CAN_EXTENDED_ID | 0x00000105);  // our ID                           
tCANParameters.ulRxIDMask = CAN_EXTENDED_MASK;
                                // use all bits for compare
tCANParameters.usMode = 0x01;      // use lpb mode
tCANParameters.ucTxBuffers = 2; // assign two tx buffers for use
tCANParameters.ucRxBuffers = 3; // assign three rx buffers for use

CAN_interface_ID = fnOpen( TYPE_CAN, FOR_I_O, &tCANParameters );


 }


static void fnSENDCAN_BUS(void)
{

unsigned char ucTestMessage[] = {1,2,3,4,5,6,7};  // Test message
if (fnWrite(CAN_interface_ID, ucTestMessage, sizeof(ucTestMessage))
                                 != sizeof(ucTestMessage)) {
    // Error. Eg. no transmission buffer free
fnDebugMsg("\n\r SENT ERROR\n\r");

}

tCANParameters.usMode = 0x01;      // use lpb mode
this is  the CAN_LOOPBACK,and the  fnWrite(CAN_interface_ID, ucTestMessage, sizeof(ucTestMessage)) is OK!
but I can't get anything from the CAN-BUS using the OSCILLOSCOPE!

what about the tCANParameters.Channel = 0;        // first hardware interface       
the 52235 have more CANTX and CANRX ,now we are use the PASPAR |= 0xa0;                                                      // configure AS port 2,3 as CAN

I don't sure the  set #define NUMBER_CAN 3,now WE are use the #define NUMBER_CAN 2.

how can I get the data?????? I don't know!

18
NXPTM M522XX, KINETIS and i.MX RT / WHY the M52235EVB can't sent data!
« on: November 16, 2007, 07:37:52 AM »
#define CAN_INTERFACE 

 case 100000:                                                    //100KHz
        CANCTRL = (((10-1) << 24) | RJW_2 | EXTAL_CLK_SOURCE | PROPSEG_BIT_TIME8 | PHASE_BUF_SEG1_LEN8 | PHASE_BUF_SEG2_LEN8);  // Initialise the CAN controller with the required speed and parameters
        break;

QUEUE_HANDLE CAN_interface_ID = 0;
static void fnConfigCAN_BUS(void)
{
CANTABLE tCANParameters; // table for passing information to driver
tCANParameters.Task_to_wake = OWN_TASK; // wake us on buffer events
tCANParameters.Channel = 0;        // first hardware interface       
 tCANParameters.ulSpeed = 100000;    // 100K speed
tCANParameters.ulTxID = 0x80;       // default ID of destination                           
tCANParameters.ulRxID = (CAN_EXTENDED_ID | 0x00000105);  // our ID                           
tCANParameters.ulRxIDMask = CAN_EXTENDED_MASK;
                                // use all bits for compare
tCANParameters.usMode = 0;      // use normal mode
tCANParameters.ucTxBuffers = 2; // assign two tx buffers for use
tCANParameters.ucRxBuffers = 3; // assign three rx buffers for use

CAN_interface_ID = fnOpen( TYPE_CAN, FOR_I_O, &tCANParameters );


 }
CAN_interface_ID is OK,and CAN_interface_ID =0x09!

static void fnSENDCAN_BUS(void)
{

unsigned char ucTestMessage[] = {1,2,3,4,5,6,7};  // Test message
if (fnWrite(CAN_interface_ID, ucTestMessage, sizeof(ucTestMessage))
                                 != sizeof(ucTestMessage)) {
    // Error. Eg. no transmission buffer free
fnDebugMsg("\n\r SENT ERROR\n\r");
}
}

but the fnSENDCAN_BUS always "SENT ERROR"!why???????


19
case 1000000:

CANCTRL = ((3 << 24) | RJW_2 | EXTAL_CLK_SOURCE | PROPSEG_BIT_TIME2 | PHASE_BUF_SEG1_LEN3 | PHASE_BUF_SEG2_LEN2);

PRESDIV=3;
RJW_2=2,
EXTAL_CLK_SOURCE =0;
PROPSEG_BIT_TIME2   (1)       =1;
PHASE_BUF_SEG1_LEN3 (2<<19)           =2;
 PHASE_BUF_SEG2_LEN2 (1<<16)   =1;
because the EXTAL_CLK=25000000;
so  Ftq = 25000000/(3+1);
Sync_Seg + Prop_Seg +Phase_Seg1 + Phase_Seg2=1+(1+1)+(2+1)+(1+1)=8
BIT RATE= Ftq /(1+1+1+2+1+1+1)!=1000000;???????ERROR????????

BUT THE
default:                                                             // 40 KHz
        CANCTRL = ((24 << 24) | RJW_2 | EXTAL_CLK_SOURCE | PROPSEG_BIT_TIME8 | PHASE_BUF_SEG1_LEN8 | PHASE_BUF_SEG2_LEN8); // Initialise the CAN controller with the required speed and parameters// Initialise the CAN controller with the required speed and parameters
PRESDIV=24;
so  Ftq = 25000000/(24+1);
Sync_Seg + Prop_Seg +Phase_Seg1 + Phase_Seg2=1+(7+1)+(7+1)+(7+1)=25
BIT RATE= Ftq /(25)=40000=40kHZ!

WHY???????make sure????which is RIGHT????????






       

20
I can't understand that :
 switch (pars->ulSpeed) {                                             // M5223X EVB
    case 1000000:
        CANCTRL = ((3 << 24) | RJW_2 | EXTAL_CLK_SOURCE | PROPSEG_BIT_TIME2 | PHASE_BUF_SEG1_LEN3 | PHASE_BUF_SEG2_LEN2); // Initialise the CAN controller with the required speed and parameters
        break;

    default:                                                             // 40 KHz
        CANCTRL = ((24 << 24) | RJW_2 | EXTAL_CLK_SOURCE | PROPSEG_BIT_TIME8 | PHASE_BUF_SEG1_LEN8 | PHASE_BUF_SEG2_LEN8); // Initialise the CAN controller with the required speed and parameters
        break;

    }
BUT I want to get the 100 khz,how can I get???


21
NXPTM M522XX, KINETIS and i.MX RT / something error #define CAN_INTERFACE!
« on: November 14, 2007, 08:42:42 AM »
if #define CAN_INTERFACE!
use the CodeWarrior IDE!

Warning : function has no prototype
M5223X.c line 3125   extern fnDumpCAN(void) 

Link Error   : Undefined : "fnOpenCAN"
Referenced from "fnOpen" in Driver.c

Link failed.

22
µTasker general / how to set the MAC address!
« on: November 08, 2007, 04:39:18 AM »
Main menu
===================
1              Configure LAN interface
2              Configure serial interface
3              Go to I/O menu
4              Go to administration menu
5              Go to overview/statistics menu
help           Display menu specific help
quit           Leave command mode

I know to the  1              Configure LAN interface
can set the MAC!
But I use the MAC 00-a0-1e-52-23-50,it is false!
I do it success long ago! I have format the flash,That is said  the first time to set mac!
can I use the "MAC" wrong!


23
µTasker general / #define SPI_FILE_SYSTEM compile ERROR!
« on: September 21, 2007, 02:45:18 AM »
Hello:
       I have  defined SPI_FILE_SYSTEM and undefined FLASH_FILE_SYSTEM!
       I want to use the fnEraseFlashSector();   fnWriteBytesFlash(); fnGetParsFile() at the ATMEL AT45DBXXX ,
       I don't want to use the SPI_SW_UPLOAD,it is too complex.No like the vxworks's bootrom,that is easy to use.
       Can that the ATMEL AT45DBXXX   only use to SPI_SW_UPLOAD no the fnEraseFlashSector();   fnWriteBytesFlash(); fnGetParsFile() ??
      Otherwise if I have the M95XXX EEPROM  ,but defined SPI_FILE_SYSTEM  it will be ERROR!
      why!

       but compil ERROR! look this:
       Error   : unexpected end of line
M5223X.c line 2112                      // uses external file system in M95XXX EEPROM 

Error   : illegal token for integral constant expression
M5223X.c line 2114       extern QUEUE_HANDLE SPI_handle; 

Error   : undefined identifier 'M95XXX_WRITE_ENABLE'
M5223X.c line 2176       static const unsigned char ucWriteEnable[] = {M95XXX_WRITE_ENABLE, TERMINATE_WRITE}; // enable write 

Error   : function has no prototype
M5223X.c line 2184           fnWaitWriteComplete();                                           // wait until free to write 

Error   : undefined identifier 'SPI_handle'
M5223X.c line 2186           fnWrite(SPI_handle, (unsigned char *)ucWriteEnable, sizeof(ucWriteEnable)); // prepare write 

Error   : function has no prototype
M5223X.c line 2187           fnWriteBytesEEPROM(ptrEEPROM, ucDel, EEPROM_PAGE_SIZE);          // delete a page 

Error   : undefined identifier 'M95XXX_WRITE_ENABLE'
M5223X.c line 2253       static const unsigned char ucWriteEnable[] = {M95XXX_WRITE_ENABLE, TERMINATE_WRITE}; // enable write 

Error   : undefined identifier 'SPI_handle'
M5223X.c line 2263           fnWrite(SPI_handle, (unsigned char *)ucWriteEnable, sizeof(ucWriteEnable)); // prepare write 

Error   : ';' expected
M5223X.c line 2464   extern SPIQue *spi_rx_control; 

Error   : undefined identifier 'M95XXX_READ_MEMORY'
M5223X.c line 2669       usRead[0] = M95XXX_READ_MEMORY; 

Error   : undefined identifier 'SPI_handle'
M5223X.c line 2675       fnWrite(SPI_handle, usRead, sizeof(usRead));                         // set the read address 

Error   : undefined identifier 'SPI_handle'
M5223X.c line 2676       fnRead(SPI_handle, ptrValue, usSize);                                // read from the device to the return buffer 


24
HELLO:
  when I #define SPI_SW_UPLOAD and undef FLASH_FILE_SYSTEM,
it is ERROR!
Error   : undefined identifier 'uFILE_START'
M5223X.c line 2089       ptrSector -= (uFILE_START + FILE_SYSTEM_SIZE);                       // location relative to the start of the SPI FLASH chi

Error   : undefined identifier 'uFILE_START'
M5223X.c line 2683       if ((ParLocation >= ((unsigned char *)(uFILE_START + FILE_SYSTEM_SIZE))) && (ParLocation < ((unsigned char *)(uFILE_START +

Error   : undefined identifier 'uFILE_START'
M5223X.c line 2716       fnGetParsFile((unsigned char*)(uFILE_START), (unsigned char *)ucValidUse, sizeof(ucValidUse)); 

Error   : undefined identifier 'uFILE_START'
M5223X.c line 2730           fnGetParsFile((unsigned char*)(uFILE_START), (unsigned char *)ucValidUse, sizeof(ucValidUse)); 


25
µTasker general / also about the AT45DB161D SPI_EEPROM use!
« on: September 20, 2007, 04:28:40 AM »
HELLO:
        In the app_hw_m5223x.h
        #define SPI_FLASH_PAGE_LENGTH 264                                        // standard page size (B-device only allows 256)
//#define SPI_FLASH_PAGE_LENGTH 256                                      // size when power of 2 mode selected (only possible on D-device)
#define SPI_FLASH_BLOCK_LENGTH (8*SPI_FLASH_PAGE_LENGTH)                 // block size - a block can be deleted
#define SPI_FLASH_SECTOR_LENGTH (64*4*SPI_FLASH_PAGE_LENGTH)             // exception sector 0a is 2k and sector 0b is 62k
#define SPI_FLASH_PAGES         1024                                     // 256k part expected
#define SPI_DATA_FLASH_SIZE    (SPI_FLASH_PAGES*SPI_FLASH_PAGE_LENGTH)

I think this is satisfy to AT45DB021:
• Page Program Operation
– Single Cycle Reprogram (Erase and Program)
– 1024 Pages (264 Bytes/Page) Main Memory

if I use the AT45DB161D must be like this
#define SPI_FLASH_PAGE_LENGTH 512                                       // standard page size (B-device only allows 256)
//#define SPI_FLASH_PAGE_LENGTH 256                                      // size when power of 2 mode selected (only possible on D-device)
#define SPI_FLASH_BLOCK_LENGTH (8*SPI_FLASH_PAGE_LENGTH)                 // block size - a block can be deleted
#define SPI_FLASH_SECTOR_LENGTH (64*4*SPI_FLASH_PAGE_LENGTH)             // exception sector 0a is 2k and sector 0b is 62k
#define SPI_FLASH_PAGES         4,096                                     // 256k part expected
#define SPI_DATA_FLASH_SIZE    (SPI_FLASH_PAGES*SPI_FLASH_PAGE_LENGTH)

AT45DB161D:
• User Configurable Page Size
– 512 Bytes per Page
– 528 Bytes per Page
• Page Program Operation
– Intelligent Programming Operation
– 4,096 Pages (512/528 Bytes/Page) Main Memory
• Flexible Erase Options
– Page Erase (512 Bytes)
– Block Erase (4 Kbytes)
– Sector Erase (128 Kbytes)
– Chip Erase (16 Mbits)
• Two SRAM Data Buffers (512/528 Bytes)

26
µTasker general / about the AT45DB161D SPI_EEPROM use!
« on: September 19, 2007, 07:46:47 AM »
Hello:
     I have the AT45DB161D chip,but the config.h only" chip size EEPROM_16K, EEPROM_32K or EEPROM_64K". this too small,the AT45DB161D  is 16-megabit. How can I use the chip size????
     In the uTasker SPI_EEPROM.doc "The necessary circuit for the SPI EEPROM is shown in appendix A. It is shown for connecting to a number of Freescale evaluation/demo boards."
     Can AT45DB161D  also use the The necessary circuit like you do????????

27
µTasker general / about the FLASH_FILE_SYSTEM USE!
« on: September 17, 2007, 09:01:56 AM »
hello:
     I have #define FLASH_FILE_SYSTEM,but I don't know how to write data to the FLASH!
     look like I have a file  asc16.bin ,how can I write asc16.bin  to the FLASH!
     I find the #ifdef _WINDOWS at the  fnWriteLongWordFlash(); what the #ifdef _WINDOWS 's function!
     In the vxworks' tffs file system I can send FILE to the flash by ftp client and I can use the FILE by use the FOPEN(); Now I have  #define USE_FTP,
and do this: ftp://ADMIN:uTasker@192.168.0.3  ,but I can't  send file to the flash in Utasker ,how can I use the file!
    WHY!??

28
µTasker general / How to use the IIC to get data and send data!
« on: September 12, 2007, 10:02:57 AM »
  I have #define IIC_INTERFACE,but  I don't how to use the IIC to get data and send data!
  In old use I use IIC as  master , look like this "UINT8 i2c_write(UINT8 slave_address, UINT8 *buffer, int byte_count)" and "UINT8 i2c_read(UINT8 slave_address, UINT8 *buffer, int byte_count)" !
  But how can use in the Utasker! I find the "extern void fnTxIIC(IICQue *ptIICQue, int iChannel)" and the "static __interrupt__ void _IIC_Interrupt(void)"!
   Can use this???
   I don't understand the "static QUEUE_TRANSFER entry_IIC(QUEUE_HANDLE channel, unsigned char *ptBuffer, QUEUE_TRANSFER Counter, unsigned char ucCallType, QUEUE_HANDLE DriverID)"!
   How to use???

29
µTasker general / How to use the timer in the uart get data!
« on: September 10, 2007, 10:54:39 AM »
HELLO:
4. In some cases (example when transferring random binary data from the serial port to somewhere else - like TCP) there is no framing possibilities. In this case each received character can be sent on but it can result in lots of short frames. A technique often used is to collect the received data in a buffer and send a packet once a certain length has been received (this optimises the frame lengths so that larger frames are sent rather than lots of short ones when there is a lot of data). However if there are only a few sporadish bytes of received data this causes a proble since they will only be sent when enough has been collected (very long pauses). To correct this a timer is used as well as the buffer. If no received data has been received for a certain amount of time (say 100ms) the buffer will also be sent, no matter how many bytes have been collected.
Working with a buffer length and a timeout it is possible to set these as parameters to acheive efficient throughput/frame size for a certain application - thsi mode of operation (including these set up parameters) is typical for RS232 <-> LAN converter operation.

look like this in the char mode :
       while  (fnMsgs(SerialPortID)) {
             Length =   fnRead( SerialPortID, ucInputMessage, BIG_MESSAGE);
                get_buff[ii]=*ucInputMessage;
                //printfk(get_buff[ii]);
               // printfk(ii);
             
                ii++;
               buff_len=ii;
               // timeout=1;
               //printfk(i);
            //  fnEchoInput(ucInputMessage, Length);
              }

     this will be right only the first time ,the second frames arrived will be wrong.Because  I don't to set ii=0 at right time to get the next frames !
    When get data I don't how to use timer to " no received data has been received for a certain amount of time "! How to get the end of the frames!
    In the Dynamic C 8.01 for rabbit it is use this to get data:
       memset(serBuffer,0,sizeof(serBuffer));
       rec_len=serBread( serBuffer, sizeof(serBuffer),SERL_REC_TIME);
       if (rec_len<=0) return;
     the rec_len is the all the frames 's number.then I can use the serBuffer to do what i want!
      if I send the 0x01 0x02 0x03 0x04 ,the rec_len will be 4.
     

30
µTasker general / also the uart use!
« on: September 08, 2007, 12:38:15 PM »
Mark:
2. Fixed message lengths.
If the received messages have random content but fixed length, they can be collected until a complete message is available. In character mode, the following could be used (called each time the task is worken by a character reception).
while (fnMsgs(SerialPortID) >= MESSAGE_LENGTH) {
    unsigned char ucBuff[MESSAGE_LENGTH];
    fnRead(SerialPortID, ucBuff, MESSAGE_LENGTH);         // read a complete message which is waiting
    fnWrite(SerialPortID, ucBuff, MESSAGE_LENGTH);        // send complete message back
}
I like to use the 2 Fixed message lengths.
but where to add the
    while (fnMsgs(SerialPortID) >= MESSAGE_LENGTH) {
    unsigned char ucBuff[MESSAGE_LENGTH];
    fnRead(SerialPortID, ucBuff, MESSAGE_LENGTH);         // read a complete message which is waiting
    fnWrite(SerialPortID, ucBuff, MESSAGE_LENGTH);        // send complete message back
}
 is in the  application.c ???
 
  #ifdef SERIAL_INTERFACE
      #ifdef TEST_MSG_MODE
          #ifdef TEST_MSG_CNT_MODE/*step 1*/
            while (fnMsgs(SerialPortID)) {
                unsigned char ucLength;

                fnRead( SerialPortID, &ucLength, 1);                     // get message length
                Length = fnRead( SerialPortID, ucInputMessage, ucLength);
                fnEchoInput(ucInputMessage, ucLength);
            }
          #else/*step 2*/
            while (fnMsgs(SerialPortID)) {
                Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE);
                fnEchoInput(ucInputMessage, Length);
            }
          #endif
      #else/*step 3*/
        if ((iAppState & (STATE_ACTIVE | STATE_DELAYING | STATE_ESCAPING | STATE_RESTARTING | STATE_VALIDATING)) && (Length = fnMsgs(SerialPortID))) {
            while ((Length = fnRead( SerialPortID, ucInputMessage, MEDIUM_MESSAGE)) != 0) {
                fnEchoInput(ucInputMessage, Length);
                if (usData_state == ES_NO_CONNECTION) {
                    if (fnCommandInput(ucInputMessage, Length, SOURCE_SERIAL)) {
                        if (fnInitiateLogin(ES_SERIAL_LOGIN) == TELNET_ON_LINE) {
                            static const CHAR ucCOMMAND_MODE_BLOCKED[] = "Command line blocked\r\n";
                            fnWrite(SerialPortID, (unsigned char *)ucCOMMAND_MODE_BLOCKED, sizeof(ucCOMMAND_MODE_BLOCKED));
                        }
                    }
                }
                else {
                    fnCommandInput(ucInputMessage, Length, SOURCE_SERIAL);
                }
            }
        }
      #endif
  #endif
  I find it always go the /*step 3*/, But I don't sure the /*step 3*/  function,it look like the TELNET function!
  I don't like to change the TELNET function! How can I do???
  can add the"2. Fixed message lengths" in fnEchoInput(ucInputMessage, Length);?????
  Regards
  tr111

Pages: 1 [2] 3