What am I doing wrong with simple gpio example?

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

What am I doing wrong with simple gpio example?

1,642 Views
Poley
Contributor V

Hi,

I have tried to run some simple models on my S32K148EVB and it seems that the push buttons do nothing.

My model is setup like shows in one of the tutorials:

Poley_0-1614607697319.png

 

The light on the board start red and stays red when button is pushed. I have linked to FreeMaster as shown and the button state never actually changes when I press it. Am I doing something obviously wrong?

 

Thank you!

0 Kudos
12 Replies

1,619 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Poley ,

The problem might be related to the data variable type of the output port or smth. I've tried with the Data Type Memory and the code seems to work. Another possibility might be the Period in which the freeMaster reads the variable I set 0 basically to read as fast as possible.

mariuslucianand_2-1614630954184.png

I have attached the model and FreeMaster example. Can you please give this a try?

Hope this helps,

Marius

0 Kudos

1,607 Views
Poley
Contributor V

Hi @mariuslucianand 

Unfortunately doesn't work.

Poley_0-1614636268165.png

Here's what I did: 

1. Extracted files to new folder
2. Build code using embedded coder

Poley_2-1614636381835.png

3. Opened FreeMaster 3.1 and loaded the project you linked.
4. Added the .elf to the map option just in case
5. Pressed GO, and value doesn't change from 0 when pressed. 

When I probe the switch with a multimeter the voltage doesn't seem to change when pressed either. I thought it could be a faulty SW but it doesn't work SW3 or SW4 on the board

Also to use digital inputs in my model do I always have to have it linked to FreeMaster? Can it not work without?

 

Thanks for the help!

0 Kudos

1,601 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Poley ,

The steps you've made are fine. I've measured on my board for the SW3. When the button is not pressed, the PT60 is 0V, when the SW3 is pressed, the PT60 is 5V.

The MCU seems to work on your side because you can connect to the FreeMaster. This is strange, can you please send me the .mot file generated to test it on my board?

For the last question, I am not sure I understand it. FreeMaster only read/write memory variables/regions. When you use FreeMaster to bring that value on your computer, basically it reads the value and sends it over UART to the Desktop application. The data store memory used, makes the process easier because it writes the button state to a volatile variable that is easier to find in the FreeMaster. MCU should read the button state and sent it to the LED even if you are using or not the FreeMaster.

Marius

 

0 Kudos

1,595 Views
Poley
Contributor V

I have 0v on the left side and 5v on the right if switches are pressed or not.

Poley_2-1614639128668.png

 

0 Kudos

1,573 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Poley 

I've tried your example and it works on my board by pressing the SW4, not SW3 as the one in your attached picture.

Let's try to bypass the switch button and put 5V to the output. You can use a write connected to the 5V, as in the attached image below, and TP61(SW4). On my setup, this turned the LED on GREEN 

mariuslucianand_0-1614670676766.png

On my setup, the logic seems to be reversed. Normally the LED is turned off, while the button is pressed the LED is lighting up. Curios.

Hope this helps,

Marius

0 Kudos

1,559 Views
Poley
Contributor V

Hi @mariuslucianand 

Bypassing the switch works:

Poley_0-1614675968465.png


I have noticed that when probing the switches I does a tiny amount. It is dead on 0v before pressed and then 6mV when pressed. Could I have faulty switches?

Poley_1-1614676080032.png

 

0 Kudos

1,552 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Poley 

There might be an issue either with the button or either with the filter circuitry. I don't know. 

mariuslucianand_0-1614683435679.png

Both of the buttons behave the same?

Marius

 

0 Kudos

1,550 Views
Poley
Contributor V

Hi @mariuslucianand 

Yes both buttons do exactly the same

0 Kudos

1,543 Views
NPXLONG
Contributor III

Hi @Poley ,

I would suggested that you should try to build your own pull down button circuit to try this GPIO example 

or else try out the ADC example to ensure your freemaster working properly as expected.

 

Regards

0 Kudos

1,537 Views
Poley
Contributor V

Hi @NPXLONG 

What do you mean sorry?

Also ADC works:

Poley_0-1614693080102.png

 

0 Kudos

1,635 Views
NPXLONG
Contributor III

Have you checked the COMPORT baudrate at device manager is that matched with your Simulink LPUART1 baudrate config?. Also you need to import the generated elf on freemaster "options" -> "map". Please ensure this procedure step is done

0 Kudos

1,631 Views
Poley
Contributor V

Hi, 

All options use the same baudrate and still does not work.

I have the .elf added to FreeMaster but the value never changes from 0.

Thanks

0 Kudos