UART on TWR-K20D50 using codewarrior with Processor Expert

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART on TWR-K20D50 using codewarrior with Processor Expert

Jump to solution
3,368 Views
Amit_Kumar1
Senior Contributor II

Hello

 

I am new to code warrior, I want to generate a project on serial communication using UART1 I have initialized the MCG to 47.972352 MHz, and I have also initialized the UART1 with 38400 baud rate. I have generated the code using Processor Expert. I am having problem in writing in the main function in ProcessorExpert.c after initialization how to use this in main function? I am not able to send any data .  I have attached my project. Please look into the matter. Is there any documentation related to how to use these generated code in main function?

 

Thanks

 

Amit Kumar

Original Attachment has been moved to: UARTtransfer.zip

1 Solution
1,854 Views
Amit_Kumar1
Senior Contributor II

Hello Miguel

thanks for replying. I configured the UART1. But Please ensure the problems are resolved which I mention below. I think it is a problem of software. when I again tried , this time I just added a component  ConsoleIO through the component library and then I simply wrote the code which you stated accordingly and it worked fine this time.

consoleio.jpg

I have just marked the component above from the code library which is supposed to be selected. but again if you select init_UART or Serial_LDD again it will have the same error. but all these configures the same things and all 3 should work one at a time. so its needed to fix this bug in code warrior 10.4.

Regards

Amit Kumar

View solution in original post

0 Kudos
Reply
7 Replies
1,855 Views
Amit_Kumar1
Senior Contributor II

Hello Miguel

thanks for replying. I configured the UART1. But Please ensure the problems are resolved which I mention below. I think it is a problem of software. when I again tried , this time I just added a component  ConsoleIO through the component library and then I simply wrote the code which you stated accordingly and it worked fine this time.

consoleio.jpg

I have just marked the component above from the code library which is supposed to be selected. but again if you select init_UART or Serial_LDD again it will have the same error. but all these configures the same things and all 3 should work one at a time. so its needed to fix this bug in code warrior 10.4.

Regards

Amit Kumar

0 Kudos
Reply
1,854 Views
miguelpalos
Contributor II

Hi Amit,

Well, you can use the main function like any other main. Can you try with writing printf("Hello World \n"); after PE_low_level_init function?

If still doesn't work, could you explain a bit more about where the problem and provide more data, as the board that you're using?

While I'll try to make a document for explain how to do.

Regards.

Miguel Palos.

1,854 Views
Amit_Kumar1
Senior Contributor II

Hi Migual

I was wondering how to receive the data from the UART? I tried

scanf("%c", &data);

but it didn't worked

0 Kudos
Reply
1,854 Views
miguelpalos
Contributor II

Hi Amit,

The function scanf belonging to library stdio should work correctly. I'm using the board: FRDM-K20D50M to test the following code and this works.

Note: I added a component more (BitIO from Component Library) in order to display the result in the board. This component named "Bit1" was configured like "output" on pin: "PTD4".

Can you check that the stdio library is included in "CsIO1.h" file in "Generated_Code" folder?, just to check that there is not the problem. (:

unsigned char lub_character_received;

/* comments */

PE_low_level_init();


/* Write your code here */

while(1)

{

      scanf("%c", &lub_character_received);

   if(lub_character_received == '0')

      {

           Bit1_PutVal(FALSE);     /* function used for BitIO component */

      }

   else if(lub_character_received == '1')

      {

           Bit1_PutVal(TRUE);

      }

   else

      { /* do nothing */ }

}

1,854 Views
Amit_Kumar1
Senior Contributor II

Hi Miguel

Thanks again it worked perfectly. I didn't get the problem but when I tried it didn't worked now it is working fine. I included the stdio. h in the main file i.e processorexpert.c I checked it was not there in any generated files so for printf i already inserted that .

Regards

Amit Kumar

0 Kudos
Reply
1,854 Views
Amit_Kumar1
Senior Contributor II

Hi Miguel

I tried the above statement as you said. but it didn't work I am getting 4 error message which is present in the attached image file. I am using TWR-K20D50M development board from freescle. I am using UART1 with PTE0 and PTE1 connections. as RxD and TXD I am using 38400 baud rate and 48Mhz system clock. I am using Code warrior 10.4 with processor expert integrated with it. How to go to the errors ? By clicking these error meg I am unable to go to the specified line numbers and files.

error msg.jpg

Regards

Amit Kumar

0 Kudos
Reply
1,854 Views
Amit_Kumar1
Senior Contributor II

I was just going through the errors and I found out that there is no folder related to TWR-K20D50M in my code warrior folder which I downloaded from freescale website !!!!!!!!!!!!! and no examples also for this board. this is too irritating Just a waste of time. I think If the board is prepared by freescale so it should have all the examples and code library for that board in the software. In this way all of us who are using TWR-K20D50M board or some similar board whose library is not provided by freescale would be wondering if their code contains problem or there is a problem with the software?? and we all will be having tough time figuring out the same. So what should be my next step for resolving this matter? While installing I installed all the components and they didn't ask for any specific development board.k20.jpgk20(1).jpg

I can see K60 board folder present but not other boards. Is there any problem while Installing Codewarrior due to which this is happening? I am using Codewarrior 10.4 integrated with processor expert.

Thanks & Regards

Amit Kumar