Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi,
I hope you are doing well. I need to set 8 pins in open drain + pull up mode and Set it output. Can I read write port? Which pins I can use as port? any example code?
Thanks
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.
But I can't see the usage of
I need to see example code in which both of above functions are used.
I am trying to read data on parallel port and sending it on uart. Trying to develop parallel to serial interface.
Parallel Pins Config, Wanted to set open drain ,pull up, and set as OUTPUT
PIN_Config parallelPinTable[] = { ParallelBit0 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit1 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit2 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit3 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit4 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit5 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit6 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, ParallelBit7 | PIN_GPIO_OUTPUT_EN | PIN_INPUT_EN | PIN_OPENDRAIN, PIN_TERMINATE };
If I use interrupt call.
UART_writePolling doesnt output any data
and
UART_write output data once and program gets stuck.
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) { currVal = PIN_getPortInputValue(ParallelPinHandle); valueRead=true; UART_writePolling(uart, &currVal, 1); // Does not outputs any data or UART_write(uart, &currVal, 1); //Programs gets stuck }
in main function
int main(void) { Task_Params taskParams; /* Call board init functions */ Board_initGeneral(); Board_initUART(); const char echoPrompt[] = "\fEchoing characters:\r\n"; /* Create a UART with data processing off. */ UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_BINARY; uartParams.readDataMode = UART_DATA_BINARY; uartParams.readReturnMode = UART_RETURN_FULL; uartParams.readEcho = UART_ECHO_OFF; uartParams.baudRate = 9600; uart = UART_open(Board_UART0, &uartParams); if (uart == NULL) { System_abort("Error opening the UART"); }
For me issue seems due to uart interrupt call inside interrupt routine.
I suggest you to use Desktop CCS and UARTecho example imported from CCS->Resource Explorer.
I tested the code below based on the documentation in the PIN.h documentation:
/* * Copyright (c) 2015-2018, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ======== empty.c ======== */ /* For usleep() */ #include <unistd.h> #include <stdint.h> #include <stddef.h> /* Driver Header files */ //#include <ti/drivers/GPIO.h> // #include <ti/drivers/I2C.h> // #include <ti/drivers/SPI.h> // #include <ti/drivers/UART.h> // #include <ti/drivers/Watchdog.h> #include <ti/drivers/PIN.h> #include <ti/drivers/pin/PINCC26XX.h> /* Board Header file */ #include "Board.h" /* Pin driver handles */ static PIN_Handle portHandle; static PIN_State portPinState; PIN_Config portPinTable[] = { CC1310_LAUNCHXL_DIO12 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, CC1310_LAUNCHXL_DIO15 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, CC1310_LAUNCHXL_DIO21 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, CC1310_LAUNCHXL_DIO22 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* 1 second delay */ uint32_t time = 1; /* Call driver init functions */ //GPIO_init(); // I2C_init(); // SPI_init(); // UART_init(); // Watchdog_init(); // Get handle to this collection of pins portHandle = PIN_open(&portPinState, portPinTable); PIN_setPortOutputValue(&portPinState, 0); while (1) { sleep(time); //GPIO_toggle(Board_GPIO_LED0); } }