From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-03-2017 05:02 PM
Working on a project where I need to get current and voltage values in the form of 4 floats that I want to convert to one buffer from a TI board (TMDSDOCK28335) and displaying the values on Labview. I have everything communicating to the best of my ability and have been able to send strings to my display. However, attempting to combine the floats and send from CCS to Labview has proven fruitless. I haven't been able to get anything displaying on Labview, not even the usual junk that will come through with bad CCS code. Below I have an image of my VI and CCS code, any pointers would be appreciated.
The C code being used is shown below as well:
/* * Test of Raw Communication */ #include "stdio.h" #include "string.h" #include "DSP28x_Project.h" #if (CPU_FRQ_150MHZ) #define ADC_MODCLK 0x3 #endif #if (CPU_FRQ_100MHZ) #define ADC_MODCLK 0x2 #endif #define ADC_CLKPS 0x0 #define ADC_SHCLK 0x0 #define BUFSIZE 256 //---PROTOTYPES------------------------------ void scia_echoback_init(void); void scia_fifo_init(void); void scia_xmit(int a); void scia_msg(char *msg); __interrupt void rxinta_isr(void); //---GLOBAL VARIABLES------------------------------ //--SCIA Variables-------------------- char msg[128]; char rxbuf[BUFSIZE]; Uint16 bufi = 0; int slen; int debug; char* testBuffer; float fl1 = 22.99999; float fl2 = 10.5; float fl3 = 0.23; float fl4 = 123.4; char totalBuff[128]; char test1[8]; char test2[8]; char test3[8]; char test4[8]; //---MAIN PROGRAM------------------------------ int main(void) { // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the DSP2833x_SysCtrl.c file. InitSysCtrl(); EALLOW; SysCtrlRegs.HISPCP.all = ADC_MODCLK; EDIS; // Step 2. Initialize all relevant GPIO pins InitSciaGpio(); // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). InitPieVectTable(); EALLOW; // This is needed to write to EALLOW protected register PieVectTable.SCIRXINTA = &rxinta_isr; PieVectTable.ADCINT = &adc_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Step 4. Initialize all the Device Peripherals: scia_echoback_init(); // Initialize SCI for echoback scia_fifo_init(); // Initialize the SCI FIFO InitAdc(); // Step 5. User specific code, enable interrupts: memset(rxbuf, 0xFF, BUFSIZE); //Clear all nulls from buffer to facilitate string checking memset(rxbuf + BUFSIZE -1, '\0', 1); //Tack a null on the end to facilitate use of strlen // Enable CPU INT9 which is connected to SCIA INT: PieCtrlRegs.PIEIER9.all = 0x0001; // Enable all SCIA RXINT interrupt IER |= 0x0100; // enable PIEIER9, and INT9 // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // Enable ADCINT in PIE PieCtrlRegs.PIEIER1.bit.INTx6 = 1; IER |= M_INT1; // Enable CPU Interrupt 1 EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM for(;;) { sprintf(test1, "%f", fl1); sprintf(test2, "%f", fl2); sprintf(test3, "%f", fl3); sprintf(test4, "%f", fl4); strcat(test1,test2); strcat(test1,test3); strcat(test1,test4); strcpy(totalBuff, test1); slen = strlen(rxbuf); if(slen < BUFSIZE - 1) { if (strcmp("DATA", rxbuf) == 0) { scia_msg(totalBuff); debug = debug +1; } else{ scia_msg("NOoo"); } memset(rxbuf, 0xff, BUFSIZE - 1); bufi = 0; } DELAY_US(100); } } void scia_echoback_init() { // Note: Clocks were turned on to the SCIA peripheral // in the InitSysCtrl() function SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback // No parity,8 char bits, // async mode, idle-line protocol SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK, // Disable RX ERR, SLEEP, TXWAKE SciaRegs.SCICTL2.all =0x0003; SciaRegs.SCICTL2.bit.TXINTENA =1; //Already in above statement //SciaRegs.SCICTL2.bit.RXBKINTENA =1; #if (CPU_FRQ_150MHZ) SciaRegs.SCIHBAUD =0x0000; // 173611 baud @LSPCLK = 37.5MHz? SciaRegs.SCILBAUD =0x0028; // #endif #if (CPU_FRQ_100MHZ) SciaRegs.SCIHBAUD =0x0000; // 9600 baud @LSPCLK = 20MHz. SciaRegs.SCILBAUD =0x001A; #endif SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset } // Transmit a character from the SCI void scia_xmit(int a) { while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {} SciaRegs.SCITXBUF=a; } void scia_msg(char * msg) { int i; i = 0; while(msg[i] != '\0') { scia_xmit(msg[i]); i++; } } // Initialize the SCI FIFO void scia_fifo_init() { SciaRegs.SCIFFTX.all=0xE040; SciaRegs.SCIFFRX.all=0x2061; SciaRegs.SCIFFCT.all=0x0; } //This interrupt offloads received characters from the hardware buffer into the software buffer rxbuf which is allocated in the main file __interrupt void rxinta_isr() { if (SciaRegs.SCIFFRX.bit.RXFFOVF) { scia_msg("FIFO_OVERFLOW!"); } while(SciaRegs.SCIFFRX.bit.RXFFST != 0){ if (bufi < BUFSIZE){ rxbuf[bufi++] = SciaRegs.SCIRXBUF.all; } else{ bufi = 0; } SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1; // clear Receive interrupt flag PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; // Acknowledge the interrupt } }
04-05-2017 06:06 AM
Wow! Usually when I rant and rave about not sending pictures of LabVIEW VIs, but rather attaching the actual VI so we can clearly see, edit, inspect, and test the code, I use as a "silly example" attaching a picture of a listing of C or Matlab code and not sending the actual .c or .m file. Well, you did just that, sent code we can only view unless we put a lot of effort into recreating your code! And how much are you paying for our efforts?
One thing I cannot tell is how you initialized your VISA device. Specifically, did you tell it to stop at a termination character? What do you see in the indicator "Read"? Does it make sense? Do you get anything?
Bob Schor
04-05-2017 06:49 AM
It looks like you are trying to converting the 32 bit data as ASCII. It usually comes across in binary format. Try using typecast instead.
04-05-2017 02:00 PM
Apologies for the information overload, first post on the forum, still learning. I was able to solve the problem by changing how my data was loaded into the buffer via C. Thank you though!
04-05-2017 02:02 PM
Was able to figure out the issue on the CCS side of things but thank you for your response! I'll look into how to implement your strategy to tackling the issue as well!
@jamiva wrote:
It looks like you are trying to converting the 32 bit data as ASCII. It usually comes across in binary format. Try using typecast instead.