hi, Iused pinmux to configure ssi0 and comparator0, after a lot of tests and modify of code I have the following errors:
someone helps me? I waste my afternoon for this!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi, Iused pinmux to configure ssi0 and comparator0, after a lot of tests and modify of code I have the following errors:
someone helps me? I waste my afternoon for this!
Hmm... You haven't defined your main() function.
You haven't brought over the header file from the pinmux programs output. You'll wan't both the .h and the .c (probably primo.h and primo.c)
Pinmux doesn't define you're whole program, just the initialization of the peripherals (SSI in your case).
1. Start with a skeleton project
If you have a project that already works, make a copy of it, and modify it.
Otherwise start with the RGB example http://processors.wiki.ti.com/index.php/Stellaris_LM4F120_LaunchPad_Blink_the_RGB and get it working. This will solve most of your pinmux problem.
2. Copy the pinmux files ( the .c and .h files) into your project. Probably create new ones if you've modified primo.c
3. Add your include
if you did the RGB example, modify project0.c to have
#include "pinmux.h" // Header file from ti's pinmux program. Change name as needed
near the top.
4. Call PortFunctionInit(); near the top of main.
Good Luck!
so, thank you, I've included all the configuration into the main() and I had to comment into pin_map.h the ifndef of the lm4f.
now, i have to handle the ssi by pushing a button, how can i create an interrupt that reads the state of the pinb_5 and start sending 16 bit on the ssi? when it's not working the clock and a pin of reset must be high, when i push the button reset goes low for 5ms and then the clock starts and the data goes out
thanks!
i wrote some code, it doesn't do nothing....
the code is this:
#include "driverlib/pin_map.h"
#include "driverlib/primo.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/ssi.h"
//*****************************************************************************
int main()
{
MAP_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
//
// Enable Peripheral Clocks
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//
// Enable port PC7 for COMP0 C0-
//
MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_7);
//
// Enable port PC6 for COMP0 C0+
//
MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_6);
//
// Enable port PF0 for COMP0 C0O
// First open the lock and select the bits we want to modify in the GPIO commit register.
//
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1;
//
// Now modify the configuration of the pins that we unlocked.
//
MAP_GPIOPinConfigure(GPIO_PF0_C0O);
MAP_GPIOPinTypeComparator(GPIO_PORTF_BASE, GPIO_PIN_0);
//
// Enable port PB7 for GPIOOutput
//
MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5); //pulsante
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_7); // PB7 come reset
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); //LED_ROSSO
//
// Enable port PA4 for SSI0 SSI0RX
//
MAP_GPIOPinConfigure(GPIO_PA4_SSI0RX);
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_4);
//
// Enable port PA3 for SSI0 SSI0FSS
//
MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);
//
// Enable port PA2 for SSI0 SSI0CLK
//
MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2);
//
// Enable port PA5 for SSI0 SSI0TX
//
MAP_GPIOPinConfigure(GPIO_PA5_SSI0TX);
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5);
GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_5);
IntMasterEnable();
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3,
SSI_MODE_MASTER, 5000, 16);
SSIEnable(SSI0_BASE);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 64);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 4);
while(1)
{}
}
void Miointerrupt(void)
{ int i;
GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_5);
if (GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5)) {
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 1);
for (i = 0; i < 20000; i++) {
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0);
}
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 64);
SSIDataPut(SSI0_BASE, 0x8000);
//while(SSI_Busy(SSI0_BASE)){}
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
}
}
The GPIOPinWrite() functions with decimal numbers in them are a little confusing here. Those should be either 0 or a GPIO_PIN_# values to get the expected behavior.
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 64); is going to set PB7 to 0 because 64 is effectively GPIO_PIN_6.
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_PIN_7); would set it to 1.
Change all these calls to specifically set the GPIO that you want and see if you get the behavior that you expect.
ok, but how can I handle interrupt with a button and use it for serial transmission?
tnx
Are you reliably getting the interrupt due to the GPIO on Port b pin 5 like you expect?
hi, no, could somone explain how handle interrupts with stellaris? it's enough to configure startup.c,the port interrupt configure and create a function out of the main() recalled in the startup on that port ? is there an example?
Thanks!
We have quite a few examples that use interrupts one is even called interrupts.c which uses software triggered GPIO interrupts. Yes to start with, you need to add your interrupt handler to the startup_ccs.c in the correct location in the table for the peripheral that you are using. Our sample startup file has each peripheral clearly commented so it is easy to find.
Your code seems to be trying to enable Port B 5 pin as an interrupt source. The following are the basic calls to enable interrupts on GPIO changes:
// Enable the peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// Enable the pin as an input.
GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5);
// Enable the type of interrupt using one of the following:
// GPIO_FALLING_EDGE, GPIO_RISING_EDGE, GPIO_BOTH_EDGES, GPIO_LOW_LEVEL, GPIO_HIGH_LEVEL
GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_BOTH_EDGES);
// Enable the interrupt on the pin.
GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_5);
// Enable the interrupts to the main processor.
IntMasterEnable();
Changes on the pin should call you interrupt handler.
ok, thanks for your help! with the analog comparator is the same code? just I need to change the interrupt handler with the name of my function in strtup_ccs.c and should work?
thanks again!