Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: HALCOGEN
Tool/software: Code Composer Studio
Hey, everyone!
Following code is what I am using to count and print high-speed. You can also find a ZIP file, containing HALCoGen and CCS project attached.5658.counter_ApurvMishra.zip
/* Include Files */
#include "HL_sys_common.h"
/* USER CODE BEGIN (1) */
#include "HL_het.h"
#include "HL_reg_het.h"
#include "HL_sci.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
void sciDisplayData(sciBASE_t *sci, uint8 *text,uint8 length);
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
/* Initialize HET driver */
hetInit();
sciInit();
edgeResetCounter(hetRAM1, edge0);
while(1)
{
uint32 counts = (uint32) edgeGetCounter(hetRAM1,edge0);
//printf(" count: %i\n",p);
sciSendByte(sciREG1,'\n');
sciDisplayData(sciREG1,(uint8*)&counts,4);
}
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
void sciDisplayData(sciBASE_t *sci, uint8 *text,uint8 length)
{
uint8 txt = 0;
uint8 txt1 = 0;
#if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
text = text + (length -1);
#endif
while(length--)
{
#if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
txt = *text--;
#else
txt = *text++;
#endif
txt1 = txt;
txt &= ~(0xF0);
txt1 &= ~(0x0F);
txt1 =txt1>>4;
if(txt<=0x9)
{
txt +=0x30;
}
else if(txt > 0x9 && txt < 0xF)
{
txt +=0x37;
}
else
{
txt = 0x30;
}
if(txt1 <= 0x9)
{
txt1 +=0x30;
}
else if((txt1 > 0x9) && (txt1 <= 0xF))
{
txt1 +=0x37;
}
else
{
txt1 = 0x30;
}
while ((sciREG1->FLR & 0x4) == 4); /* wait until busy */
sciSendByte(sciREG1,txt1); /* send out text */
while ((sciREG1->FLR & 0x4) == 4); /* wait until busy */
sciSendByte(sciREG1,txt); /* send out text */
};
}
/* USER CODE END */
digital pulses.
I am using serial to print data fast but I need to print the data (here, 'counts') as it is, in decimal only. The following converts it into hexadecimal.
Please, help me here.
Thanks and regards,
Apurv