Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Scardini

  1. Hello bluehash, I trie to work with SCIA module with interrupts. In the RX pin (GPIO 28), the interruption is occurring at time of the overflow (5 characters received), always losing the first character. However the interruption had been set to occur on every character received (SCI_FifoLevel_1_Word). In the attached code, the error described occurs. It should blink an LED for each received character (in the interruption) however the LED blinks only on every five characters group received. The code is complete, put on ccs and run.... on computer, use the putty ( or similar ) to test the problem. I believe it is a configuration error, but it may be some error in the api or SCIA module. Thank's Scardini
  2. Anyone have any idea where is the error? trey?
  3. This function is declared in _DEBUG scope. Only is visible if the _DEBUG is declared on compile / link steps. To enable the _DEBUG define, go to : Project -> properties -> Build -> C2000 Compiler -> Advanced Options -> Predefined Symbols and include the _DEBUG symbol on Pre-define Name field. good luck
  4. Hello, Do not know if it's my mistake or a fault in interrupt module. I tried to receive data from the SCIA module using only the system interruption. The interrupt is generated only every five characters received in order to always miss the first character. Even when I set the interrupt to occur in SCI_FifoLevel_1_Word status. #include "DSP28x_Project.h" // DSP28x Headerfile #include "f2802x_common/include/pll.h" #include "f2802x_common/include/clk.h" #include "f2802x_common/include/wdog.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/sci.h" extern void DSP28x_usDelay(Uint32 Count); interrupt void sciaRxFifoIsr(void); // principais CPU_Handle myCpu; PLL_Handle myPll; WDOG_Handle myWDog; CLK_Handle myClk; GPIO_Handle myGpio; PIE_Handle myPie; SCI_Handle mySci; void setup_handles() { myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj)); myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj)); myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj)); myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj)); myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj)); mySci = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj)); return; } void init_system() { // desabilito o WatchDog WDOG_disable(myWDog); // Endereço da rotina de calibração do oscilador interno (*Device_cal)(); // seleciono o oscilador interno CLK_setOscSrc(myClk, CLK_OscSrc_Internal); // Seleciono o clock de 60Mhz PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2); // desabilito o controlador de interrupções PIE_disable(myPie); // desabilito as interrupções PIE_disableAllInts(myPie); // desabilito as interrupções globais CPU_disableGlobalInts(myCpu); // Limpo todos os flags de interrupções CPU_clearIntFlags(myCpu); // If running from flash copy RAM only functions to RAM #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif return; } void init_gpio(){ // configuro os leds GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_1, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_2, GPIO_0_Mode_GeneralPurpose); GPIO_setMode(myGpio, GPIO_Number_3, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output); GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output); // inicializo os leds ( all off ) GPIO_setHigh(myGpio, GPIO_Number_0); GPIO_setHigh(myGpio, GPIO_Number_1); GPIO_setHigh(myGpio, GPIO_Number_2); GPIO_setHigh(myGpio, GPIO_Number_3); // SCI RX pin GPIO_setPullUp(myGpio, GPIO_Number_28, GPIO_PullUp_Enable); GPIO_setQualification(myGpio, GPIO_Number_28, GPIO_Qual_ASync); GPIO_setMode(myGpio, GPIO_Number_28, GPIO_28_Mode_SCIRXDA); } void init_pie(){ // Setup a debug vector table and enable the PIE PIE_setDebugIntVectorTable(myPie); PIE_enable(myPie); // Interrupt that is used in this example are re-mapped to ISR functions found within this file. // This is needed to write to EALLOW protected registers EALLOW; // PieVectTable.SCIRXINTA = &sciaRxFifoIsr; ((PIE_Obj *)myPie)->SCIRXINTA = &sciaRxFifoIsr; // This is needed to disable write to EALLOW protected registers EDIS; // Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(myPie, PIE_GroupNumber_9, PIE_SubGroupNumber_1, (intVec_t)&sciaRxFifoIsr); } void init_scia(){ // Habilito o clock CLK_enableSciaClock(myClk); // Defino formato 8N1 SCI_disableParity(mySci); SCI_setNumStopBits(mySci, SCI_NumStopBits_One); SCI_setCharLength(mySci, SCI_CharLength_8_Bits); // 115200 ( 60 Mhz main clock ) SCI_setBaudRate(mySci, SCI_BaudRate_115_2_kBaud); // inicialmente desabilito TX e RX SCI_disableRx(mySci); SCI_disableTx(mySci); // desabilito as interrupções SCI_disableRxInt(mySci); SCI_disableTxInt(mySci); // ativa a interface serial SCI_enable(mySci); } void init_scia_fifo(){ // Habilita o FIFO SCI_enableFifoEnh(mySci); // FIFO interrupts - disabled SCI_disableRxFifoInt(mySci); // fifo RX interrupt disabled SCI_disableTxFifoInt(mySci); // fifo TX interrupt disabled } void init_scia_rx_int(){ // RX - inicialização SCI_enableRx(mySci); SCI_enableRxInt(mySci); SCI_enableRxFifoInt(mySci); SCI_setRxFifoIntLevel(mySci, SCI_FifoLevel_1_Word); SCI_clearRxFifoInt(mySci); SCI_setPriority(mySci, SCI_Priority_FreeRun); // Enable interrupts required for this example PIE_enableInt(myPie, PIE_GroupNumber_9, PIE_InterruptSource_SCIARX); SCI_clearRxFifoOvf(mySci); CPU_enableInt(myCpu, CPU_IntNumber_9); CPU_enableGlobalInts(myCpu); return; } void PiscaLed0(){ GPIO_setLow(myGpio, GPIO_Number_0); DSP28x_usDelay(100000); GPIO_setHigh(myGpio, GPIO_Number_0); return; } void PiscaLed3(){ GPIO_setLow(myGpio, GPIO_Number_3); DSP28x_usDelay(100000); GPIO_setHigh(myGpio, GPIO_Number_3); return; } interrupt void sciaRxFifoIsr(void){ PiscaLed3(); while(SCI_getRxFifoStatus(mySci) != SCI_FifoLevel_Empty){ uint16_t ch = SCI_getData(mySci); PiscaLed0(); DSP28x_usDelay(500000); } // Clear Overflow flag SCI_clearRxFifoOvf(mySci); // Clear Interrupt flag SCI_clearRxFifoInt(mySci); // Issue PIE ack PIE_clearInt(myPie, PIE_GroupNumber_9); return; } void main() { setup_handles(); init_system(); init_gpio(); init_pie(); init_scia(); init_scia_fifo(); init_scia_rx_int(); for(;{ asm (" NOP"); } } What is wrong? Cristiano Scardini
  5. Hello Trey, Going beyond the question raised by the Skinny, I wonder if it is possible to associate the stdout and stdin to SCIA? I saw an example where this was done with the stdout: //Redirect STDOUT to SCI status = add_device("scia", _SSA, SCI_open, SCI_close, SCI_read, SCI_write, SCI_lseek, SCI_unlink, SCI_rename); fid = fopen("scia","w"); freopen("scia:", "w", stdout); setvbuf(stdout, NULL, _IONBF, 0); How this code becomes to add the stdin? thanks Cristiano Scardini
  • Create New...