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.


Messages - kingston

Pages: [1] 2
1
NXPTM M522XX, KINETIS and i.MX RT / Re: K64 SPI Slave example
« on: July 05, 2018, 10:32:44 AM »
Hi,

my colleague found the solution:

On page 1446 in the K64 reference manual there is a table which describes that only CS0 can be used in slave mode...
Would be nice if they thought about mentioning this somewhere more prominent.

Anyway with CS0 I get all the RX interrutps that didn't work before.

Thanks for your help!

Regards

Paul

2
NXPTM M522XX, KINETIS and i.MX RT / Re: K64 SPI Slave example
« on: July 04, 2018, 08:46:02 AM »
Hi Mark,

thank you for the quick response!

I'm using SPI0 on a K64 with CS4 as chip select:

PTC0 SPI0_CS4
PTD1 SPI0_SCK
PTD2 SPI0_MOSI (SOUT)
PTD3 SPI0_MISO (SIN)

Right now I have configured the RX interrupt but it never occurs.

I have only little time today so I will try again tomorrow.

Regards

Paul


Here is my code for the initialisation:

Code: [Select]
              _CONFIG_PERIPHERAL(C, 0, (PC_0_SPI0_PCS4));
_CONFIG_PERIPHERAL(D, 1, (PD_1_SPI0_SCK | PORT_SRE_FAST | PORT_DSE_HIGH));
_CONFIG_PERIPHERAL(D, 2, (PD_2_SPI0_SOUT));
_CONFIG_PERIPHERAL(D, 3, (PD_3_SPI0_SIN));
SPI0_MCR = SPI_MCR_HALT;
SPI0_CTAR0 = (SPI_CTAR_FMSZ_8 | SPI_CTAR_CPHA | SPI_CTAR_CPOL);
SPI0_RSER = (SPI_SRER_RFDF_RE);
SPI0_MCR = (SPI_MCR_SLAVE | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF);
CLEAR_RECEPTION_FLAG();
fnEnterInterrupt(irq_SPI0_ID, PRIORITY_TIMERS, fnHandleSPI);

3
NXPTM M522XX, KINETIS and i.MX RT / K64 SPI Slave example
« on: July 03, 2018, 01:26:41 PM »
Hi all,

has anyone already used the K64 as a SPI slave?
I'm trying to talk to an ESP8266 as a SPI-wifi bridge but can't get the SPI on the K64 to work in slave mode.

So far I have set the module to slave mode like this:
SPI0_MCR = (SPI_MCR_SLAVE | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF);

and have configured the CS line as an input with a ISR when the edge is falling.

In my ISR I check for SPI0_SR & SPI_SR_RFDF to see if there is data available but there never is.

Also when I put data into SPI0_PUSHR_SLAVE I never see a change in the SDO line on my logic analyzer.

I know there are some CMSIS examples for a DSPI Slave on K64 and it is also mentioned in the reference manual but I couldn't get it to work.

Any help would be appreciated.

Thanks

Paul

4
LCD Graphics Library and Simulator / Re: FT800
« on: August 14, 2017, 07:36:45 AM »
Hi Mark,

here are the SPI changes needed to make the display work on our KBED64 (set config to FRDMK64):

app_hw_kinetis.h:

Code: [Select]
#if defined FT800_GLCD_MODE                                              // {31}
    #define ENABLE_BACKLIGHT()

#define LCD_SPI_MCR SPI1_MCR
#define LCD_SPI_SR SPI1_SR
#define LCD_SPI_POPR SPI1_POPR

    //#define FLUSH_LCD_SPI_FIFO_AND_FLAGS()      SPI1_MCR |= SPI_MCR_CLR_RXF; SPI1_SR = (SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF)
#define FLUSH_LCD_SPI_FIFO() LCD_SPI_MCR |= (SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF); //clear fifo and fifo-counter of rx/tx fifo
#define FLUSH_LCD_SPI_FLAGS() LCD_SPI_SR = (SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF);
#define FLUSH_LCD_SPI_FIFO_AND_FLAGS() FLUSH_LCD_SPI_FIFO();FLUSH_LCD_SPI_FLAGS();

#define CLEAR_LCD_SPI_RECEPTION_FLAG()      LCD_SPI_SR |= SPI_SR_RFDF

#define WAIT_LCD_SPI_RECEPTION_END()        while (!(SPI1_SR & SPI_SR_RFDF)) {};
#define READ_LCD_SPI_FLUSH_DATA()           (unsigned char)LCD_SPI_POPR
#define FLUSH_LCD_SPI_DATA() (void) LCD_SPI_POPR

#define FT800_SPI_CTAR_CSSCK 0x000002000 //time cs enable ->sck
#define FT800_SPI_CTAR_ASC 0x000000200 //time sck ->cs disable (time after sck)
#define FT800_SPI_CTAR_DT 0x000000020 //time cs min. disabled (required 0)

    #define CONFIGURE_GLCD()          POWER_UP(6, SIM_SCGC6_SPI1);\
                                      _CONFIG_PORT_OUTPUT(A, PORTA_BIT2,PORT_SRE_FAST);_CLEARBITS(A, PORTA_BIT2);\
                                      _CONFIG_PERIPHERAL(E, 4, (PE_4_SPI1_PCS0 | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                      _CONFIG_PERIPHERAL(E, 2, (PE_2_SPI1_SCK | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                      _CONFIG_PERIPHERAL(E, 1, (PE_1_SPI1_SOUT | PORT_SRE_FAST | PORT_DSE_HIGH));\
                                      _CONFIG_PERIPHERAL(E, 3, PE_3_SPI1_SIN);\
                                      SPI1_MCR = (SPI_MCR_MSTR | SPI_MCR_DCONF_SPI | SPI_MCR_CLR_RXF | SPI_MCR_CLR_TXF | SPI_MCR_PCSIS_CS0 | SPI_MCR_PCSIS_CS1 | SPI_MCR_PCSIS_CS2 | SPI_MCR_PCSIS_CS3 | SPI_MCR_PCSIS_CS4 | SPI_MCR_PCSIS_CS5);\
                                      SPI1_CTAR0 = (SPI_CTAR_FMSZ_8 | SPI_CTAR_PDT_7 | SPI_CTAR_BR_4 | FT800_SPI_CTAR_CSSCK | FT800_SPI_CTAR_ASC | FT800_SPI_CTAR_DT);
    #if !defined _WINDOWS
        #define _FT8XXEMU_cs(x)
        #define _FT8XXEMU_transfer(x)
    #endif
#define WRITE_LCD_SPI_CMD0_FIRST(byte)      FLUSH_LCD_SPI_FIFO_AND_FLAGS(); _FT8XXEMU_cs(1); WRITE_LCD_SPI_CMD0(byte); // assert the chip select line and send a byte
    #define WRITE_LCD_SPI_CMD0(byte)            SPI1_PUSHR = (byte | SPI_PUSHR_CONT | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); _FT8XXEMU_transfer(byte); WAIT_LCD_SPI_RECEPTION_END(); FLUSH_LCD_SPI_DATA(); CLEAR_LCD_SPI_RECEPTION_FLAG();// write a single byte to the output FIFO - assert CS line
    #define WRITE_LCD_SPI_CMD0_LAST(byte)       SPI1_PUSHR = (byte | SPI_PUSHR_EOQ | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); WAIT_LCD_SPI_RECEPTION_END(); FLUSH_LCD_SPI_DATA(); _FT8XXEMU_transfer(byte); _FT8XXEMU_cs(1); // write final byte to output FIFO - this will negate the CS line when complete




    #if defined _WINDOWS
        #define READ_LCD_SPI_CMD0(byte, value) SPI1_PUSHR = (byte | SPI_PUSHR_CONT | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); value = _FT8XXEMU_transfer(byte)
        #define READ_LCD_SPI_CMD0_LAST(byte, value) SPI1_PUSHR = (byte | SPI_PUSHR_EOQ | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); value = _FT8XXEMU_transfer(byte); _FT8XXEMU_cs(1)
    #else
        #define READ_LCD_SPI_CMD0(byte, value)  SPI1_PUSHR = (byte | SPI_PUSHR_CONT | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); WAIT_LCD_SPI_RECEPTION_END(); value = READ_LCD_SPI_FLUSH_DATA(); CLEAR_LCD_SPI_RECEPTION_FLAG()
        #define READ_LCD_SPI_CMD0_LAST(byte, value) SPI1_PUSHR = (byte | SPI_PUSHR_EOQ | SPI_PUSHR_PCS0 | SPI_PUSHR_CTAS_CTAR0); WAIT_LCD_SPI_RECEPTION_END(); value = READ_LCD_SPI_FLUSH_DATA(); CLEAR_LCD_SPI_RECEPTION_FLAG()
    #endif
    #define FLUSH_LCD_SPI_RX(count)    //  (void)SPI1_POPR; CLEAR_LCD_SPI_RECEPTION_FLAG();     //{int i = count; while (i != 0) {WAIT_LCD_SPI_RECEPTION_END(); (void)SPI1_POPR; CLEAR_LCD_SPI_RECEPTION_FLAG(); i--;}}
    #define GLCD_RST_L()              _CLEARBITS(A, PORTA_BIT2);
    #define GLCD_RST_H()              _SETBITS(A, PORTA_BIT2);
    #if defined _WINDOWS
        #define MAX_GLCD_WRITE_BURST   10000                             // the maximum number of writes to the GLCD before the task yields
    #else
        #define MAX_GLCD_WRITE_BURST   1000                              // the maximum number of writes to the GLCD before the task yields
    #endif

  //#define GLCD_BACKLIGHT_CONTROL                                       // (requires SUPPORT_PWM_MODULE)
  //#define TEMP_HUM_TEST
  //#define VARIABLE_PIXEL_COLOUR                                        // support control of background and pixel colors

    #define _GLCD_BACKLIGHT_TIMER         6                              // PWM channel 6 (TC)
    #define _GLCD_TIMER_MODE_OF_OPERATION (PWM_PRESCALER_128 | PWM_SCALED_CLOCK_INPUT | PWM_POLARITY)
    #define _GLCD_BACKLIGHT_PWM_FREQUENCY (unsigned char)(PWM_US_DELAY(PWM_FREQUENCY_VALUE(2000 * 128)))
#endif

Thank you for your hard work!

5
LCD Graphics Library and Simulator / Re: FT800
« on: August 07, 2017, 09:38:34 AM »
Hi Mark,

I will talk to my colleague as soon as I see him and let you know the details :)

Regards

Paul

6
USB / Re: USB-CDC Host
« on: August 07, 2017, 09:30:22 AM »
Hi Mark,

I was out of the office for the last two weeks so I did not check it again.
I will leave debugging running over night and will tell you the result.

Regards

Paul

7
Hi Mark,

just wanted to inform you that my colleague got it working!

He is not in the office yet so I can't give you the details but he told me yesterday that it had to do mainly with wrong SPI timings.

Regards

Paul

8
Thank you Mark I got it working in the emulator as well now! I will check my wiring now and see if I can make it run on the real board :)

BTW:

There seems to be still a bug in the USB-Host functions where it gets stuck requesting the IN token.
I can't really reproduce it but it happens sometimes after half an hour and sometimes after 5 hours :)


EDIT:

I got the SPI communication working on my K64 device and even get 0x7c after some time but the display stays dark :/

It looks like this was a coincidence as I couldn't reproduce the 0x7c afterwards...

You use "FLUSH_LCD_SPI_RX(4);" when writing/reading from the coprocessor but I had to comment it out for my software to work as there were never 4 bytes to flush (only 2).
I haven't found this flush in other FT81X libraries can you explain if and why it is needed?

9
Hi Mark,

we are using this eval kit:
http://www.watterott.com/de/5-800x480-Display-mit-kapazitivem-Touchscreen-FT811CB-HY50HD

It is connected to our KBED64 (similiar to FRDMK64) for test purposes.

I will try to build the vanilla project for FRDM-K64 and see if it works.

Regards

Paul



------------------------

I tried it with a FRDM-K64 and KEIL can compile just fine.
When I put the firmware on the board with the same pin config you used (SPI0 and PORTC_BIT5) the display does nothing and the LCD tasks never leaves "STATE_INITIALISING_4".
As this is the first occurence of a read command (Ft_Gpu_Hal_Rd8) and it always returns 0xff I think the problem could be with my connections.

Will have to recheck everything on monday

10
As usually I did not try the simulator sorry :)
We wanted to try a color/touchscreen display for some time now so when we read about the FT800 support we ordered a FT811 evaluation kit and wanted to try it directly with our hardware.

I'm currently tied up in a project so I can't put a lot of time into getting this to work but I will try again later.

"Can you otherwise load and run the KDS build if you don't try to debug it?" I tried but it did not run for some reason.

I will report back as soon as I have more info!

Regards

Paul

PS: Thank you for the usb stack fixes, all my problems seem to be gone :)

11
Hi Mark,

I have a problem when trying to use the new FT800 feature.
As soon as I set all the required defines (SUPPORT_GLCD, FT800_GLCD_MODE, FT_800_ENABLE) KEIL cannot compile the project anymore and gives the following error:
Code: [Select]
.\Objects\EKFullDemo_KBED64.axf: Internal fault: [0xb3b91b:5060300]
.\Objects\EKFullDemo_KBED64.axf: Please contact your supplier.

When I compile with KDS it works but when I start debugging with Segger it crashes the gdb-server at 99% when the application should launch.

Also does the library already support FT81X too? If not do you plan on supporting those in the future?

Thank you!

Paul

12
Great news Mark! Thank you for your hard work

13
µTasker general / Re: HTML element
« on: June 14, 2016, 09:20:12 AM »
Hi Mircea,

what we are doing in our projects to load data via javascript is the following:

1. Create a handler for you commands in "fnHandleWeb" in webInterface.c

Code: [Select]
        if(uMemcmp(ptrData,"#yourCmd",8) == 0){ 
return fnHandleDynamicQuery(ptrData, http_session);
}

This will check if the string after the / in the URL is "#yourCmd"  (e.g. 192.168.0.1/#yourCmd)
The # sign is there because there is no webPage starting with this char.

2. Set up the handler:

Code: [Select]
char fnHandleDynamicQuery(CHAR *ptrData, HTTP *http_session){
    char buff[BUFF_SIZE] = {0}; //create a buffer with specified size
    uMemset(buff,0,BUFF_SIZE);  //empty the buffer

                //fill the buffer here with the data you would like to display


                //set the Buffer as file to be displayed
                http_session->ptrFileStart = (unsigned char*)buff;
                http_session->ucMimeType   = MIME_HTML;                          // force HTML type
                http_session->cDisplayFile = 0;
                http_session->FileLength   = len; //len is the length of the data you inserted into the buffer

                return DISPLAY_INTERNAL;
}


3. Get the code with Javascript in your webpage (keyword: XMLHttpRequest)

I hope this helps you

Regards

Paul

14
µTasker general / GZIP compression support for webserver
« on: July 01, 2015, 12:18:49 PM »
Hello,

i am currently working on a project which has very limited storage in the SPI-flash but still needs a "fancy" website with a lot of javascript.
As javascript libraries are often over hundred kilobytes in size they waste space needed for other things.

I remembered reading about gzip compression for webservers but always thought the server would need to compress the files before sending them to the client.
After stumbling across another article it became clear to me that this is not the case and the only thing needed is an entry in the HTTP-header to inform the client that the data is compressed.

With this in mind I modified the HTTP-stack to fill in the needed information:

Code: [Select]
#if defined SUPPORT_GZIP_SERVING
static unsigned short fnAddContentTypeGZIP(CHAR *ptrBuffer, const CHAR *ptrType)
{
    CHAR *ptrContent = ptrBuffer;
    ptrContent = uStrcpy(ptrContent, "Content-Type: ");
    ptrContent = uStrcpy(ptrContent, ptrType);
    ptrContent = uStrcpy(ptrContent, "\r\n");
    ptrContent = uStrcpy(ptrContent, "Content-Encoding: gzip\r\n\r\n");

    return ((ptrContent - (CHAR *)ptrBuffer) - 2);
}
#endif

static unsigned short fnAddMimeContent(unsigned char *ptrBuffer, unsigned char ucMimeType)
{
    switch (ucMimeType) {
    #if defined MIME_TXT
    case MIME_TXT:
        return (fnAddContentType((CHAR *)ptrBuffer, "text/plain"));
    #endif
    #if defined MIME_CSS
    case MIME_CSS:
        return (fnAddContentType((CHAR *)ptrBuffer, "text/css"));
    #endif
    #if defined MIME_JAVA_SCRIPT
    case MIME_JAVA_SCRIPT:
        return (fnAddContentType((CHAR *)ptrBuffer, "application/javascript"));
    #endif
    #if defined MIME_PNG
    case MIME_PNG:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/png"));
    #endif
    #if defined MIME_JPG
    case MIME_JPG:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/jpg"));
    #endif
    #if defined MIME_BMP
    case MIME_BMP:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/bmp"));
    #endif
    #if defined MIME_GIF
    case MIME_GIF:
        return (fnAddContentType((CHAR *)ptrBuffer, "image/gif"));
    #endif
#if defined SUPPORT_GZIP_SERVING
    case MIME_JAVA_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "application/javascript"));
        break;
    case MIME_CSS_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "text/css"));
        break;
    case MIME_HTML_GZIP:
          return (fnAddContentTypeGZIP((CHAR *)ptrBuffer, "text/html"));
        break;
#endif
    default:
        return 0;
    }
}
#endif

The function fnAddContentTypeGZIP adds the mime-type and an additional string "Content-Encoding: gzip" to the HTTP-header.

The new defines e.g. MIME_JAVA_GZIP have to be defined at the end of config.h for this to work. I added custom file extensions like jgz for compressed java and cgz for compressed css:

Code: [Select]
#if defined OPSYS_CONFIG                                                 // this is only set in the hardware module
    #if defined ETH_INTERFACE                                            // if we support Ethernet we define some constants for its (TCP/IP) use
        const unsigned char cucNullMACIP[MAC_LENGTH] = { 0, 0, 0, 0, 0, 0 };
        const unsigned char cucBroadcast[MAC_LENGTH] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; // used also for broadcast IP
    #endif

    #if defined SUPPORT_MIME_IDENTIFIER
    const CHAR *cMimeTable[] = {                                         // keep the ordering in the table to match the MIME type defines below!!
        (const CHAR *)"HTM",                                             // HTML file - will be interpreted by web server
        (const CHAR *)"JPG",                                             // JPG image
        (const CHAR *)"GIF",                                             // GIF image
        (const CHAR *)"CSS",                                             // CSS Cascading Style Sheets
        (const CHAR *)"JS",                                              // Java script
        (const CHAR *)"BIN",                                             // binary data file
        (const CHAR *)"TXT",                                             // text data file
(const CHAR *)"ICO",                                             // icon
        (const CHAR *)"BMP",                                             // BMP image
#ifdef  SUPPORT_GZIP_SERVING
(const CHAR *)"JGZ",                                             // gzipped javascript
(const CHAR *)"CGZ",                                             // gzipped css
(const CHAR *)"HGZ",                                             // gzipped html
#endif
        (const CHAR *)"???",                                             // all other types will be displayed as unknown
    };
    #endif
#endif

// File type identifiers
//
#define MIME_HTML                  0                                     // this and any lower types will be parsed by the web server
#define MIME_JPG                   1
#define MIME_GIF                   2
#define MIME_CSS                   3
#define MIME_JAVA_SCRIPT           4
#define MIME_BINARY                5
#define MIME_TXT                   6
#define MIME_ICON                  7
#define MIME_BMP                   8
#ifdef SUPPORT_GZIP_SERVING
#define MIME_JAVA_GZIP    9
#define MIME_CSS_GZIP    10
#define MIME_HTML_GZIP    11
#define UNKNOWN_MIME               12                                     // this entry is needed to terminate the list
#else
#define UNKNOWN_MIME               9                                     // this entry is needed to terminate the list
#endif

The new mime types get set when you write a file with one of the extensions to your storage.

I was able to get the filesize down to a fifth of the original so this really speeds up things. (179k -> 31k)

The only caveat I could find is that the original insert mechanisms with the pound-sign will not work when using a compressed HTML-file but as I am not using them anymore it doesn't really matter to me.

Maybe this will help others too when dealing with limited storage.

Kind Regards

Paul




15
Hi Mark,

we are using a custom board based on the K60 V2 and the KSZ8081 in interrupt mode.
The project is based on uTasker 1.4.7 so the fix is already included but it never worked for us prior to the change of the define.

Thanks for your response!

Kind regards

Paul

Pages: [1] 2