9 Replies Latest reply on Sep 23, 2013 4:49 AM by userc_43229

    UART usage in Large Memory Model

    userc_43229

       I am using the psoc5.4 designer and created a project using an uart.

         

      This project was working fine. Until I changed the paging attribute in the project settings.

         

      My own code is only C I didn;t modify the assembler parts. 

         

      So I may expect that the uart_1.asm and uart_1int.asm are correct and do support the LMM.

         

      When Paging is enabled I see the UART_1_bRxCnt getting a value.

         

      But the UART_1_aRxBuffer is filled with 0x00

         

      What should I do to get the LMM working in combination with the uart.

        • 1. Re: UART usage in Large Memory Model
          userc_40792
                  Hi Geert   
          Which PSoC device did you use?   
          LMM; I assumed it Cy8C29*** device.   
          Where is use that UART API?   
          In interrupt routine? or main polling loop?   
          or both combined?   
             
          Did you use context save and restore MACRO?   
          like this in the interrupt routine   
          ... PRESERVE_CPU_CONTEXT   
          ... lcall _ISRC_TxComplete   
          ... RESTORE_CPU_CONTEXT   
          • 2. Re: UART usage in Large Memory Model
            JoMe_264151
                    Whenever possible upload your complete project here, using Designer's "Archive Project" function, so we all can have a look at your internal settings etc.   
               
            Bob   
            • 3. Re: UART usage in Large Memory Model
              userc_43229

               I use the CY8C29666-24PVXI

              • 4. Re: UART usage in Large Memory Model
                userc_43229

                 I do not use the PRESERVER_CPU_CONTEXT

                   

                The uart is interupt enabled. Receiving is done by interupt.

                   

                And in my C code I check the UART_1_bRxCont

                   

                In include uartc.h function  void uart_ontvangen(void)

                   

                I am however not able to debug with the ICE module. Because my psoc is togetter with other components in plastic.

                   

                So I can not connect to the psoc chip.

                • 5. Re: UART usage in Large Memory Model
                  userc_40792
                          Basically, In the interrupt routine RAM segment assign to Interrupt RAM area.   
                  That is first 256 byte, 0 - 255 byte.   
                  If your buffer area is place without interrupt RAM area,   
                  you can't access with it directly from interrupt routine.   
                  So, you have to call these save/restore MACRO.   
                     
                  in_the_interrupt(void)   
                  {   
                  ... PRESERVE_CPU_CONTEXT   
                  ... lcall _ISRC_UserProcess ;; CALL USER PROCESS   
                  ... RESTORE_CPU_CONTEXT   
                  }   
                     
                  // USER CALL BACK ROUTINE //   
                  void ISRC_UserProcess(void)   
                  {   
                  // access your buffer   
                  ... return;   
                  }   
                  • 6. Re: UART usage in Large Memory Model
                    userc_43229

                     Do I need to modify the uart_1.asm or uart_1INT.asm for that ???

                    • 7. Re: UART usage in Large Memory Model
                      userc_43229

                       I am not using an own (C code) Interup routine. So from the _UART_1_RX_ISR there is no call like you describe.
                      Maybe such a routine can be a workaround for my problem. (But then I need an example. how to implement such a routine.) 

                         

                      Because I am just a beginner in PSOC development.

                      • 8. Re: UART usage in Large Memory Model
                        userc_40792

                        OK     

                         

                           

                        This is a real code of my Cy8C29466 – UART     

                         

                           

                        Something help for you.     

                         

                           

                             

                                    

                           

                        ;-------------------------------------------------------     

                         

                           

                        ; In the UARTINT.asm     

                         

                           

                        ;-------------------------------------------------------     

                         

                           

                        _UART_RX_ISR:     

                         

                           

                           ;@PSoC_UserCode_BODY_2@ (Do not change this line.)     

                         

                           

                           ;     

                         

                           

                           ;---------------------------------------------------     

                         

                           

                           ; Insert a lcall to a C function below this banner     

                         

                           

                           ;---------------------------------------------------     

                         

                           

                           PRESERVE_CPU_CONTEXT     

                         

                           

                           lcall _ISRC_RxReady     

                         

                           

                           RESTORE_CPU_CONTEXT     

                         

                           

                           ;---------------------------------------------------     

                         

                           

                           ; Insert a lcall to a C function above this banner     

                         

                           

                           ;---------------------------------------------------     

                         

                           

                           ;@PSoC_UserCode_END@ (Do not change this line.)     

                         

                           

                             

                                    

                           

                        // ////////////////////////////////////////////////////     

                         

                           

                        // this is a user process in main.c     

                         

                           

                        // ////////////////////////////////////////////////////     

                         

                           

                        volatile byte RxFlag, RxIdx, RxLen;     

                         

                           

                        volatile byte RxBuf[UART_BUF_SIZE];     

                         

                           

                        // ////////////////////////////////////////////////////     

                         

                           

                        // in this routine, STX code 0x02 is start of record     

                         

                           

                        //    CR code 0x0D is end of record     

                         

                           

                        // this routine handle only text data 0x20 ~     

                         

                           

                        // ////////////////////////////////////////////////////     

                         

                           

                        void ISRC_RxReady(void)       // receive data ready     

                         

                           

                        { byte ss;     

                         

                           

                                   

                         

                           

                              if( (UART_bReadRxStatus()&UART_RX_REG_FULL) && !(UART_bReadRxStatus()&UART_RX_ERROR) )     

                         

                           

                              {     ss= UART_bReadRxData();     

                         

                           

                                    if( ss==STX )                      

                         

                           

                                    {     RxIdx= 0;                     // if start text: clear pointer     

                         

                           

                                    }     

                         

                           

                                    else if( ss>=' ' )                  // if text data     

                         

                           

                                    {     RxBuf[RxIdx++]= ss;           //    set buffer     

                         

                           

                                          if( RxIdx>=UART_BUF_SIZE-1 )  // if exceed data     

                         

                           

                                          {     RxIdx= UART_BUF_SIZE-1;     

                         

                           

                                                RxBuf[RxIdx]= 0;        // complete buffer     

                         

                           

                                                RxLen= RxIdx;     

                         

                           

                                                RxIdx= 0;     

                         

                           

                                                RxFlag= 1;              // record comleted     

                         

                           

                                    }     }          

                         

                           

                                    else if( ss==CR )                   // if end of text     

                         

                           

                                    {   if( RxIdx )     

                         

                           

                                          {     if( RxIdx>=UART_BUF_SIZE-1 ) RxIdx= UART_BUF_SIZE-1;     

                         

                           

                                                RxBuf[RxIdx]= 0;        // complete buffer     

                         

                           

                                                RxLen= RxIdx;     

                         

                           

                                                RxIdx= 0;     

                         

                           

                                                RxFlag= 1;              // record comleted     

                         

                           

                              }     }     }     

                         

                           

                        }     

                         

                           

                             

                                    

                           

                        // ///////////////////////////////////////////////////////////////////     

                         

                           

                        void UART_Initialize(void)     

                         

                           

                        {   UART_Start(UART_PARITY_ODD);      // Parity Odd       

                         

                           

                            UART_EnableInt();     

                         

                           

                            UART_IntCntl(UART_ENABLE_RX_INT); // Enable RX interrupts     

                         

                           

                        }     

                         

                           

                             

                                    

                           

                        // ///////////////////////////////////////////////////////////////////     

                         

                           

                        byte UART_Receive( byte rec[], byte siz )     

                         

                           

                        { byte len;     

                         

                           

                              if( !RxFlag ) return 0;     

                         

                           

                              if( siz>=UART_BUF_SIZE-1 ) siz= UART_BUF_SIZE-1;       

                         

                           

                              len= RxLen;     

                         

                           

                              RxLen= 0;     

                         

                           

                              if( siz<len ) len= siz;     

                         

                           

                              strncpy( rec, (char*)RxBuf, len );     

                         

                           

                              RxFlag= 0;     

                         

                           

                              return len;       

                         

                           

                        }     

                         

                           

                             

                                    

                           

                        // ///////////////////////////////////////////////////////////////////     

                         

                           

                        int main(void)     

                         

                           

                        { byte ss, rec[UART_BUF_SIZE];     

                         

                           

                             

                                    

                           

                        UART_Initialize();     

                         

                           

                            M8C_EnableGInt;         // enable global interrupts     

                         

                           

                             

                                    

                           

                              While(true)     

                         

                           

                        {     if( ss=UART_Receive(rec, UART_BUF_SIZE) )     

                         

                           

                                    {     

                         

                           

                                      // do something using rec[]     

                         

                           

                              }     }     

                         

                           

                        }          

                         

                           

                        // ///////////////////////////////////////////////////////////////////     

                         

                           

                             

                                    

                        • 9. Re: UART usage in Large Memory Model
                          userc_43229
                                  Thanks for your support and for the sample code. I found already that the issue I have is not memory model related.