Tiva C, Matlab,

Hi all,

I have a Tiva-C board that I configure with Keil. I want to perform a simple task - when my MATLAB runs a specific command, I want to send an "On" trigger (analogoutput 3.3V) to a NI PCI Board to start a camera device. Also, I am relativley new in programming in Keil. I have the following questions:

I have a small program that turns a connected LED on and off.

option 1 - Is it possible to write 2 function ledON/ledOFF that can be executed from MATLAB (without a main)? Something like -

  // Make PA2 high
void LED_On(void){
  GPIO_PORTA_DATA_R |= 0x04;
}
// Make PA2 low
void LED_Off(void){
  GPIO_PORTA_DATA_R &= ~0x04;
}

option 2 - should I load a program that runs in a loop and performs the task according to a "package" sent from MATLAB? Something like -

  int main(void){
  LED_Init();               // initialize PA2 and make it output
  while(1){
  In = GPIO_PORTF_DATA_R&0x10;   // read PF4 (read 'input' from matlab)
ChangeLedState(In);'
  }

2) What is the most recommended way to interface a the Keil C-format files with MATLAB? What signal should it read, and how do I specify and connect to a specific GPIO port?

Any further wise suggestion is welcomed...

Noam

Parents
  • Let's think about other "controllable" devices around you, and consider what methods other people/companies might have chosen...

    Isn't it quite common that devices that may be controlled from a PC is using RS232, USB or Ethernet to receive their commands - unless they are newer in which case they are nowadays mostly wireless?

    Using a digital input pin to control a digital output pin feels quite strange - if you already have a digital signal you wouldn't need any microcontroller outside of the PC.

    So how about using RS232? If your PC doesn't have any RS232 port, you can use a USB-to-serial adapter - there are cables with the conversion electronics integrated.

Reply
  • Let's think about other "controllable" devices around you, and consider what methods other people/companies might have chosen...

    Isn't it quite common that devices that may be controlled from a PC is using RS232, USB or Ethernet to receive their commands - unless they are newer in which case they are nowadays mostly wireless?

    Using a digital input pin to control a digital output pin feels quite strange - if you already have a digital signal you wouldn't need any microcontroller outside of the PC.

    So how about using RS232? If your PC doesn't have any RS232 port, you can use a USB-to-serial adapter - there are cables with the conversion electronics integrated.

Children
More questions in this forum