.txt file input for I2C application or file read function for LPC1114/301

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

.txt file input for I2C application or file read function for LPC1114/301

8,448件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Apr 11 05:23:29 MST 2012
[SIZE=4][B][COLOR=Blue]Hi...!!!
I want to take/read file(.txt format doc format) continuously as an input for one of my application on I2C.
But when I use FILE *file and file =fopen("filename.txt","r"); it is   showing error and I tried few more things but it is showing error.
I have used #include "debug_printf.h" , #include "stdlib.h" and other required driver files, but still error is coming.

Please guide me on this or share any document available on c functions for LPCxpresso.

Thanks....:)[/COLOR][/B][/SIZE]
0 件の賞賛
返信
85 返答(返信)

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Thu May 09 04:08:27 MST 2013
Hi

Is this piece of code Ok.


[COLOR=Blue][B]#if 1
  LPC_SYSCON->PRESETCTRL |= (0x1<<1);//
#else
  LPC_SYSCON->PRESETCTRL |= (0x1<<0);
#endif
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);
  LPC_IOCON->PIO0_4 &= ~0x3F;    /*  I2C I/O config */
  LPC_IOCON->PIO0_4 |= 0x01;        /* I2C SCL */
  LPC_IOCON->PIO0_5 &= ~0x3F;    //
  LPC_IOCON->PIO0_5 |= 0x01;        /* I2C SDA *[/B][/COLOR]




Quote: researchinnovation
Hi...!!!

Can we change here the settings of registers of I2C SCL and SDA, what  would be the consequences ; and how can we see these register values on  LPCxpresso IDE; is there any other way of checking the register value  than what is shown in the image.

[COLOR=Blue][B]#if 1
  LPC_SYSCON->PRESETCTRL |= (0x1<<1);//
#else
  LPC_SYSCON->PRESETCTRL |= (0x1<<0);
#endif
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);
  LPC_IOCON->PIO0_4 &= ~0x3F;    /*  I2C I/O config */
  LPC_IOCON->PIO0_4 |= 0x01;        /* I2C SCL */
  LPC_IOCON->PIO0_5 &= ~0x3F;    //
  LPC_IOCON->PIO0_5 |= 0x01;        /* I2C SDA */.[/B][/COLOR]

0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Mon Nov 26 03:55:28 MST 2012
Any luck.
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Sun Jul 22 23:47:49 MST 2012
Hi...!!!

Can we change here the settings of registers of I2C SCL and SDA, what  would be the consequences ; and how can we see these register values on  LPCxpresso IDE; is there any other way of checking the register value  than what is shown in the image.

[COLOR=Blue][B]#if 1
  LPC_SYSCON->PRESETCTRL |= (0x1<<1);//
#else
  LPC_SYSCON->PRESETCTRL |= (0x1<<0);
#endif
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);
  LPC_IOCON->PIO0_4 &= ~0x3F;    /*  I2C I/O config */
  LPC_IOCON->PIO0_4 |= 0x01;        /* I2C SCL */
  LPC_IOCON->PIO0_5 &= ~0x3F;    //
  LPC_IOCON->PIO0_5 |= 0x01;        /* I2C SDA */.[/B][/COLOR]
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Jun 27 04:02:48 MST 2012
Hi...!!!

Can we change here the settings of registers of I2C SCL and SDA, what would be the consequences ; and how can we see these register values on LPCxpresso IDE; is there any other way of checking the register value than what is shown in the image.

[COLOR=Blue][B]#if 1
  LPC_SYSCON->PRESETCTRL |= (0x1<<1);//
#else
  LPC_SYSCON->PRESETCTRL |= (0x1<<0);
#endif
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);
  LPC_IOCON->PIO0_4 &= ~0x3F;    /*  I2C I/O config */
  LPC_IOCON->PIO0_4 |= 0x01;        /* I2C SCL */
  LPC_IOCON->PIO0_5 &= ~0x3F;    //
  LPC_IOCON->PIO0_5 |= 0x01;        /* I2C SDA */[/B][/COLOR]



Thanks & Regards...:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Jun 27 03:00:18 MST 2012
Hi...!!!
 
Can we change here the settings of registers of I2C SCL and SDA; and how can we see these register values on LPCxpresso IDE.

[COLOR=Blue][B]#if 1
  LPC_SYSCON->PRESETCTRL |= (0x1<<1);
#else
  LPC_SYSCON->PRESETCTRL |= (0x1<<0);
#endif
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);
  LPC_IOCON->PIO0_4 &= ~0x3F;    /*  I2C I/O config */
  LPC_IOCON->PIO0_4 |= 0x01;        /* I2C SCL */
  LPC_IOCON->PIO0_5 &= ~0x3F;   
  LPC_IOCON->PIO0_5 |= 0x01;        /* I2C SDA */[/B][/COLOR]


Thanks & Regards....:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Mon Jun 25 22:01:13 MST 2012
Hi...!!!

[B][COLOR=Navy]case 0x28:    /* Data byte has been transmitted, regardless ACK or NACK */
    if ( WrIndex < I2CWriteLength )
    {  
      LPC_I2C->DAT = I2CMasterBuffer[WrIndex++]; /* this should be the last one */
      printf("  In IRQ_handler data is transmitted to I2C bus  \t:: %s\n\n",&I2CMasterBuffer[2]);//important
    //printf("\t%x",LPC_I2C->DATA_BUFFER);  //20-06-12

    }
    else
    {
      if ( I2CReadLength != 0 )
      {
        LPC_I2C->CONSET = I2CONSET_STA;    /* Set Repeated-start flag */
      }
      else
      {
        LPC_I2C->CONSET = I2CONSET_STO;      /* Set Stop flag */
        I2CMasterState = I2C_OK;
      }
    }
    LPC_I2C->CONCLR = I2CONCLR_SIC;
    break;
   
[/COLOR][/B]



[COLOR=Red][U][B]OUTPUT:--------[/B][/U][/COLOR]


  In main reading from file                 :: 123467
  In IRQ_handler data is transmitted to I2C bus      :: 123467


  In main reading from file                 :: 89qwer
  In IRQ_handler data is transmitted to I2C bus      :: 89qwer


  In main reading from file                 :: tyujkd
  In IRQ_handler data is transmitted to I2C bus      :: tyujkd


  In main reading from file                 :: unetwr
  In IRQ_handler data is transmitted to I2C bus      :: unetwr


  In main reading from file                 :: sbhnmd
  In IRQ_handler data is transmitted to I2C bus      :: sbhnmd


  In main reading from file                 :: kjteui
  In IRQ_handler data is transmitted to I2C bus      :: kjteui


  In main reading from file                 :: .end
  In IRQ_handler data is transmitted to I2C bus      :: .end




Thanks & Regards......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Mon Jun 25 05:05:49 MST 2012
Hi...!!!

This is working.....!!!

#ifdef __USE_CMSIS
#include "LPC11xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>
#include "filehandler.h"
#include "filehandlerconfig.h"
#include <stdio.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

extern uint8_t I2CMasterBuffer[BUFSIZE];
int main(void) {
    int j=0;
    FILE *fh;
    ErrCode Err = ERR_OK;


    Err = InitialiseI2C();

    fh=fopen(FILENAME, FILEOPENMODE);
    while (!feof(fh))
    {
        fread(&I2CMasterBuffer[2],1,BUFSIZE-2, fh);
        printf("\n  In main reading from file \t\t\t\t:: %s\n",&I2CMasterBuffer[2]);
        Err = TxI2C();
        for(j=0;j<BUFSIZE-2;j++)
            I2CMasterBuffer[j+2]=0;
    }
    fclose(fh);

    return 0 ;
}



Thanks & Regards.....:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Mon Jun 25 03:29:27 MST 2012

Quote: atomicdog
Please start using the code tags. It makes it a lot easier to read your code, which means it's more likely someone will try to help.

[ CODE ][ /CODE ]


Hi...!!!

Thanks for your kind suggestion, I will do so.


Thanks & Regards.....:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Sat Jun 23 18:29:02 MST 2012

Quote: researchinnovation
Hi....!!!

Check this out...!!



Please start using the code tags. It makes it a lot easier to read your code, which means it's more likely someone will try to help.

[ CODE ][ /CODE ]
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Sat Jun 23 00:16:14 MST 2012
Hi....!!!

Check this out...!!

nt main(void) {
    int mm;
    FILE *fh;
    ErrCode Err = ERR_OK;

    //Err = FileOpen (&fh);

    extern char I2CMasterBuffer[BUFSIZE];
    //char *I2CMasterBufferPtr=I2CMasterBuffer;
    Err = InitialiseI2C();
//    Err = FileOpen (fh);
//    Err = FileRead(fh,I2CMasterBuffer);
    fh=fopen(FILENAME, FILEOPENMODE);
    while (!feof(fh))
    {
        fread(fh,BUFSIZE,1, I2CMasterBuffer);
        Err = TxI2C();
    }
    fclose(fh);

    return 0 ;
}



Thanks & Regards......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Thu Jun 21 02:07:59 MST 2012
Hi...!!!


Is  this sequence of calling functions wrong(Passing data to I2C)...!!!

[COLOR=DarkRed][B]int main(void) {
    filehandle_t fh=NULL;
    ErrCode Err = ERR_OK;

    Err = FileOpen (&fh);

    extern char I2CMasterBuffer[BUFSIZE];
    //char *I2CMasterBufferPtr=I2CMasterBuffer;

    Err = FileOpen (&fh);
    Err = FileRead(fh,I2CMasterBuffer);
    Err = InitialiseI2C();//modified on 20_06_12
    Err = TxI2C();

    Err = FileClose (fh);
    return 0 ;
}
[/B][/COLOR]

Thanks & Regards......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Tue Jun 19 01:51:22 MST 2012

Quote: CodeRedSupport
See the FAQ Linker Error "cannot find -l<lib_name>"

Note that it is always worth doing a search when you encounter an error like this. The sticky post at the top of the forum explains how to do this.

Regards,
CodeRedSupport




Thanks a lot for your kind reply......!!!


Thanks & Regards....:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 19 00:30:22 MST 2012
See the FAQ Linker Error "cannot find -l<lib_name>"

Note that it is always worth doing a search when you encounter an error like this. The sticky post at the top of the forum explains how to do this.

Regards,
CodeRedSupport
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Mon Jun 18 03:56:37 MST 2012
Hi...!!!

What could be the reason of following Error:-


[COLOR=Navy][B]Building target: i2c_eeprom.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -Xlinker --gc-sections -Xlinker -Map=i2c_eeprom.map -mcpu=cortex-m0 -mthumb -T "lpcxpresso1114_blinky_Debug.ld" -o"i2c_eeprom.axf"  ./src/adc.o ./src/can.o ./src/clkconfig.o ./src/core_cm0.o ./src/cr_startup_lpc11.o ./src/crp.o ./src/debug_printf.o ./src/eeprom.o ./src/gpio.o ./src/i2c.o ./src/i2cslave.o ./src/lpc_swu.o ./src/main.o ./src/rs485.o ./src/small_gpio.o ./src/ssp.o ./src/system_LPC11xx.o ./src/timer16.o ./src/timer32.o ./src/uart.o ./src/wdt.o   -lLib_EaBaseBoard -lLib_MCU -lLib_CMSISv1p30_LPC11xx
c:/nxp/lpcxpresso_4.1.5_219/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lLib_EaBaseBoard
c:/nxp/lpcxpresso_4.1.5_219/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lLib_MCU
c:/nxp/lpcxpresso_4.1.5_219/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lLib_CMSISv1p30_LPC11xx
collect2: ld returned 1 exit status
make: *** [i2c_eeprom.axf] Error 1[/B][/COLOR]


Thanks & Regards.....:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Sun Jun 17 23:20:38 MST 2012
Hi..!!!

This attached project is not working properly, not able to get/receive data on "I2CRdBuffer" and "I2CMasterBuffer", can anybody tell what is wrong with this code.



Thanks & Regards......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Wed Jun 13 04:00:02 MST 2012
So have you actually looked at your RAM utilisation, as I previously suggested? If your heap and stack collide then all sorts of issues are likely to occur.
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Jun 13 03:51:14 MST 2012
Wow! Great error!!!
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Jun 13 03:40:02 MST 2012
Hi....!!!

Have a look on this Error....!!


Thanks & Regards......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Wed Jun 13 02:27:03 MST 2012
Hi....!!!


Have a look on it.....!!



Thanks & Regards.......:)
0 件の賞賛
返信

4,175件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Tue Jun 12 23:59:56 MST 2012
Hi.....Whitecoe..!!!

Thanks a lot for your kind reply. Let me try once again and then get back to you.


Thanks & Regards....:)
0 件の賞賛
返信