PSoC4: Creating custom component

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
joth_1413401
Level 1
Level 1

Hi Everyone,

   

                         I an trying to create a custom component using UART. After watching the training videos and the Component Author Guide,I was able to create the Schematic and the Symbol only. I tried to create the API's but i don't think its the right way to do so.

   

 

   

What i did was, I tried to use to use the commands like "UART_Start()" in the API ; The compiler is giving me warning implicit declaration f function "UART_Start()" is invalid in C99.

   

Kindly give your feedback as many other out there would be wishing to create their own component.

   

 

   

Regards,

   

Joji 

0 Likes
16 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Joji, without looking into your project, check the "..._Start()" line, instead of "UART_Start()" it should be something like "UART_1_Start()", where "UART_1" - is actual name of UART component on the schematic.  

0 Likes

I had changed the name of the component used in the schematic  to UART. So its clear from that point of view.

   

I have a doubt if we can declare it that way?

   

Anyways thanks for the reply.

0 Likes
lock attach
Attachments are accessible only for community members.
joth_1413401
Level 1
Level 1

For clear understanding i am attaching the project file.

   

Actually for basic I need to create a component that takes the input from keyboard and stores it to a location till a \n is received and then increments the address of the location.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

I currently have no access to computer to check your project, .. include header file at the top of UART_test.c file

   

#include <`$INSTANCE_NAME`.h>

0 Likes

I tried writing #include <`$INSTANCE_NAME`.h> but the error still persist. 

   

Earlier I was writing #include <project.h>

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you place your generates component onto your topdesign sheet and start a build you will see what you have to correct.

   

 

   

Bob

0 Likes

Its showing that there is problem in the c file.

   

The problem is that my way for defining the function like UART_Start() or UART_Enable() is not correct. And don't know the correct way to do so. Thats what i need to know. 

   

If  you have any example regarding the component creation of UART then it would be helpful, as i need to see how the API files are created.

   

Regards,

   

Joji 

0 Likes
        I did as you have said and found out that the error is in my c file. The way i am defining the functions in the c file is not correct. like UART_Start(), UART_Enable(); and I don't know how to correct them that's what i need to know. If you have any projects or any links for creating the component using UART then it would be helpful. Regards, Joji   
0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Joji,

   

... replace as:
 
void `$INSTANCE_NAME`_Start(){

   

     //UART_Start(); //missing component instance name

   

    `$INSTANCE_NAME`_UART_Start();
   
}

   

 

   

also in header file add separator after 'void'

   


    //void`$INSTANCE_NAME`_Start(); //typo

   

    void `$INSTANCE_NAME`_Start();

0 Likes

Thanks for the reply, it solved my error . I had lost hope, thanks again.

   

I will create the custom component and will post it. If someone can benefit from this then its good

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

You are welcome, I learned something too 🙂

0 Likes
joth_1413401
Level 1
Level 1

Hi again, 

   

      This time its the interrupt!! The custom component that we were discussing above had an Interrupt attached with it. Its going into the ISR routine but now its not clearing the interrupt status, hence its not coming out of the ISR routine.  Here I have registered the ISR in the c file.

   

I am attaching the project file if someone could help then it would be great.

   

Regards

   

Joji

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Attaching project?

   

 

   

Bob

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        Joji, you haven't attached the project. Move ISR routine into API *.c file.   
0 Likes
lock attach
Attachments are accessible only for community members.
joth_1413401
Level 1
Level 1

Sorry I forgot to attach the Project, i am attaching the file now.

   

and odissey1 I have declared the ISR routine into API *.c file.

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Joji,

   

there is not much code in your project and ISR routine. Other thought: you send UART_Tx message inside ISR routine, which is blocking operation, which is not good. I am attaching an example of UART_Rx which you can wrap into component or use it as working example.

0 Likes