fix:uart output issue caused by clkdiv; feat: spi

This commit is contained in:
IOsetting 2021-12-30 22:48:21 +08:00
parent 6477d1281a
commit 9e8bd90cbd
23 changed files with 171 additions and 111 deletions

View File

@ -42,8 +42,7 @@ INTERRUPT(ADC_Routine, EXTI_VectADC)
void main(void)
{
SYS_Init();
SYS_SetClock();
// For debug print
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
// Set ADC1(GPIO P1.1) HIP

View File

@ -62,7 +62,7 @@ INTERRUPT(ADC_Routine, EXTI_VectADC)
void main(void)
{
SYS_Init();
SYS_SetClock();
// For debug print
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
// Channel: ADC1

View File

@ -32,7 +32,7 @@
void main(void)
{
uint16_t res;
SYS_Init();
SYS_SetClock();
// For debug print
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
// Set ADC1(GPIO P1.1) HIP
@ -51,7 +51,7 @@ void main(void)
ADC_Start();
NOP();
NOP();
while (!ADC_SamplingUnfinished());
while (!ADC_SamplingFinished());
ADC_ClearInterrupt();
/*
res = ADC_RESL;

View File

@ -32,7 +32,7 @@
void main(void)
{
uint8_t res;
SYS_Init();
SYS_SetClock();
// For debug print
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
// Set ADC1(GPIO P1.1) HIP
@ -51,7 +51,7 @@ void main(void)
ADC_Start();
NOP();
NOP();
while (!ADC_SamplingUnfinished());
while (!ADC_SamplingFinished());
ADC_ClearInterrupt();
res = ADC_RES;

View File

@ -93,18 +93,16 @@ INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
void main(void)
{
SYS_Init();
// Set system clock. Remove this line if system clock is already set by STC-ISP
SYS_SetClock();
// UART1 configuration: baud 115200 with Timer2, 1T mode, no interrupt
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
// Timer0 configuration: 1T mode, 16-bit auto-reload, frequency 1000, interrupt enabled
TIM_Timer0_Config(
HAL_State_ON,
TIM_TimerMode_16BitAuto,
1000,
HAL_State_ON,
EXTI_IntPriority_High);
TIM_Timer0_SetRunState(HAL_State_ON);
// Timer0 configuration: 16-bit auto-reload, interrupt enabled
TIM_Timer0_Config(HAL_State_ON, TIM_TimerMode_16BitAuto, 1000);
EXTI_Timer0_SetIntState(HAL_State_ON);
EXTI_Timer0_SetIntPriority(EXTI_IntPriority_High);
EXTI_Global_SetIntState(HAL_State_ON);
TIM_Timer0_SetRunState(HAL_State_ON);
while(1);
}

View File

@ -14,17 +14,14 @@ INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
void main(void)
{
SYS_Init();
// Set system clock. Remove this line if system clock is already set by STC-ISP
SYS_SetClock();
// UART1 configuration: baud 115200 with Timer1, 1T mode, no interrupt
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer1, HAL_State_ON, 115200, HAL_State_OFF);
TIM_Timer0_Config(HAL_State_ON, TIM_TimerMode_16BitAuto, 1000);
EXTI_Timer0_SetIntState(HAL_State_ON);
EXTI_Timer0_SetIntPriority(EXTI_IntPriority_High);
EXTI_Global_SetIntState(HAL_State_ON);
TIM_Timer0_Config(
HAL_State_ON,
TIM_TimerMode_16BitAuto,
1000,
HAL_State_ON,
EXTI_IntPriority_High);
TIM_Timer0_SetRunState(HAL_State_ON);
while(1);
}

View File

@ -1,7 +1,5 @@
#include "fw_hal.h"
static uint8_t counter = 0;
INTERRUPT(Timer2_Routine, EXTI_VectTimer2)
{
UART1_TxString("hello\r\n");
@ -9,12 +7,13 @@ INTERRUPT(Timer2_Routine, EXTI_VectTimer2)
void main(void)
{
SYS_Init();
SYS_SetClock();
// UART1 configuration: baud 115200 with Timer1, 1T mode, no interrupt
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer1, HAL_State_ON, 115200, HAL_State_OFF);
EXTI_Global_SetIntState(HAL_State_ON);
// 12T mode, prescaler:255+1, frequency: 1, interrupt: ON
TIM_Timer2_Config(HAL_State_OFF, 0xFF, 1, HAL_State_ON);
TIM_Timer2_Config(HAL_State_OFF, 0xFF, 1);
EXTI_Timer2_SetIntState(HAL_State_ON);
EXTI_Global_SetIntState(HAL_State_ON);
TIM_Timer2_SetRunState(HAL_State_ON);
while(1);

View File

@ -14,12 +14,14 @@ INTERRUPT(Timer2_Routine, EXTI_VectTimer2)
void main(void)
{
SYS_Init();
SYS_SetClock();
// UART1 configuration: baud 115200 with Timer1, 1T mode, no interrupt
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer1, HAL_State_ON, 115200, HAL_State_OFF);
EXTI_Global_SetIntState(HAL_State_ON);
// 1T mode, prescaler:255+1, frequency: 5, interrupt: ON
TIM_Timer2_Config(HAL_State_ON, 0xFF, 5, HAL_State_ON);
TIM_Timer2_Config(HAL_State_ON, 0xFF, 5);
EXTI_Timer2_SetIntState(HAL_State_ON);
EXTI_Global_SetIntState(HAL_State_ON);
TIM_Timer2_SetRunState(HAL_State_ON);
while(1);

View File

@ -9,7 +9,8 @@ INTERRUPT(UART1_Routine, EXTI_VectUART1)
void main(void)
{
SYS_Init();
SYS_SetClock();
// UART1, baud 115200, baud source Timer2, 1T mode, interrupt on
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_ON);
UART1_SetRxState(HAL_State_ON);
while(1)

View File

@ -2,7 +2,8 @@
void main(void)
{
SYS_Init();
SYS_SetClock();
// UART1, baud 115200, baud source Timer2, 1T mode, no interrupt
UART1_ConfigMode1Dyn8bitUart(UART1_BaudSource_Timer2, HAL_State_ON, 115200, HAL_State_OFF);
while(1)
{

View File

@ -2,7 +2,8 @@
void main(void)
{
SYS_Init();
SYS_SetClock();
// UART2, baud 115200, baud source Timer2, 1T mode, no interrupt
UART2_ConfigMode0Dyn8bitUart(HAL_State_ON, 115200, HAL_State_OFF);
while(1)
{

View File

@ -20,7 +20,7 @@
#define ADC_SetPowerState(__STATE__) SFR_ASSIGN(ADC_CONTR, 7, __STATE__)
#define ADC_Start() SFR_SET(ADC_CONTR, 6)
#define ADC_SamplingUnfinished() (ADC_CONTR & (0x01 << 5))
#define ADC_SamplingFinished() (ADC_CONTR & (0x01 << 5))
#define ADC_ClearInterrupt() SFR_RESET(ADC_CONTR, 5)
#define ADC_SetPWMTriggerState(__STATE__) SFR_ASSIGN(ADC_CONTR, 4, __STATE__)
/**

View File

@ -54,6 +54,10 @@
#define __CONF_FOSC 24000000UL
#endif
#ifndef __CONF_CLKDIV
#define __CONF_CLKDIV 0x00
#endif
#ifndef __CONF_IRCBAND
#define __CONF_IRCBAND 0x00
#endif

View File

@ -24,6 +24,7 @@
#include "fw_tim.h"
#include "fw_uart.h"
#include "fw_adc.h"
#include "fw_spi.h"
#include "fw_util.h"
#endif

67
include/fw_spi.h Normal file
View File

@ -0,0 +1,67 @@
// Copyright 2021 IOsetting <iosetting@outlook.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ___FW_SPI_H___
#define ___FW_SPI_H___
#include "fw_conf.h"
#include "fw_types.h"
/**
* STC8H1K08(TSSOP20) STC8H3K32S2(TSSOP20)
* #1 #4 #1 #3 #4
* SPI SS -> 1 16 19 7 16(P35)
* SPI MOSI -> 2 15 15(P34)
* SPI MISO -> 3 14 14(P33)
* SPI CLK -> 4 13 13(P32)
*/
typedef enum
{
// SS MOSI MISO SCLK
SPI_AlterPort_P12P54_P13_P14_P15 = 0x00,
SPI_AlterPort_P22_P23_P24_P25 = 0x01,
SPI_AlterPort_P54_P40_P41_P43 = 0x10,
SPI_AlterPort_P35_P34_P33_P32 = 0x11,
} SPI_AlterPort_t;
typedef enum
{
SPI_ClockPreScaler_4 = 0x00,
SPI_ClockPreScaler_8 = 0x01,
SPI_ClockPreScaler_16 = 0x02,
SPI_ClockPreScaler_32or2 = 0x03,
} SPI_ClockPreScaler_t;
#define SPI_RxTxFinished() (SPSTAT & (0x01 << 7))
#define SPI_ClearInterrupt() SFR_RESET(SPSTAT, 7)
#define SPI_ClearWriteConflictInterrupt() SFR_RESET(SPSTAT, 6)
#define SPI_IgnoreSlaveSelect(__STATE__) SFR_ASSIGN(SPCTL, 7, __STATE__)
#define SPI_SetEnableState(__STATE__) SFR_ASSIGN(SPCTL, 6, __STATE__)
#define SPI_SetDataOrderLSB(__STATE__) SFR_ASSIGN(SPCTL, 5, __STATE__)
#define SPI_SetMasterMode(__STATE__) SFR_ASSIGN(SPCTL, 4, __STATE__)
// CPOL, 0:idle low, 1:idl high
#define SPI_SetClockPolarHigh(__STATE__) SFR_ASSIGN(SPCTL, 3, __STATE__)
// CPHA, 0:SS low drive, 1:SCLK front edge drive
#define SPI_SetClockFrontEdgeDrive(__STATE__) SFR_ASSIGN(SPCTL, 2, __STATE__)
/**
* SPI Clock
*/
#define SPI_SetClockPrescaler(__PRE_SCALER__) (SPCTL = SPCTL & ~0x03 | ((__PRE_SCALER__) << 0))
/**
* Alternative port selection
*/
#define SPI_SwitchPort(__ALTER_PORT__) (P_SW1 = P_SW1 & ~(0x03 << 2) | ((__ALTER_PORT__) << 2))
#endif

View File

@ -18,13 +18,6 @@
#include "fw_conf.h"
#include "fw_types.h"
#define SYS_SetFOSC(__IRCBAND__, __VRTRIM__, __IRTRIM__, __LIRTRIM__) do { \
IRCBAND = ((__IRCBAND__) & 0x03); \
VRTRIM = (__VRTRIM__); \
IRTRIM = (__IRTRIM__); \
LIRTRIM = ((__LIRTRIM__) & 0x03); \
} while(0)
/**
* STC8H Clock:
* MCKSEL ||===> MCLKODIV ==> MCLKO_S => P1.6/P5.4
@ -33,10 +26,17 @@
* 10 External 32KHz |
* 11 Internal 32KHz |
*/
void SYS_Init(void);
#define SYS_SetFOSC(__IRCBAND__, __VRTRIM__, __IRTRIM__, __LIRTRIM__) do { \
IRCBAND = ((__IRCBAND__) & 0x03); \
VRTRIM = (__VRTRIM__); \
IRTRIM = (__IRTRIM__); \
LIRTRIM = ((__LIRTRIM__) & 0x03); \
} while(0)
void SYS_SetClock(void);
void SYS_Delay(uint16_t t);
void SYS_DelayUs(uint16_t t);
void SYS_SetSysClkDiv(uint8_t div);
uint32_t SYS_GetSysClk(void);
uint32_t SYS_GetSysClock(void);
#endif

View File

@ -27,6 +27,7 @@ typedef enum
TIM_TimerMode_16BitAutoNoInt = 0x03 // Uninterruptable 16-bit auto-reload, Timer0 only
} TIM_TimerMode_t;
int16_t TIM_Timer0n1_CalculateInitValue(uint16_t frequency, HAL_State_t freq1t, uint16_t limit);
/***************************** /
* Timer 0
@ -42,12 +43,7 @@ typedef enum
#define TIM_Timer0_SetMode(__TIM_TIMER_MODE__) (TMOD = TMOD & ~(0x03 << 0) | ((__TIM_TIMER_MODE__) << 0))
#define TIM_Timer0_SetInitValue(__TH__, __TL__) do{ TH0 = (__TH__); TL0 = (__TL__); }while(0)
void TIM_Timer0_Config(
HAL_State_t freq1t,
TIM_TimerMode_t mode,
uint16_t frequency,
HAL_State_t intState,
EXTI_IntPriority_t intPriority);
void TIM_Timer0_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency);
/***************************** /
@ -64,12 +60,7 @@ void TIM_Timer0_Config(
#define TIM_Timer1_SetMode(__TIM_TIMER_MODE__) (TMOD = TMOD & ~(0x03 << 4) | ((__TIM_TIMER_MODE__) << 4))
#define TIM_Timer1_SetInitValue(__TH__, __TL__) do{ TH1 = (__TH__); TL1 = (__TL__); }while(0)
void TIM_Timer1_Config(
HAL_State_t freq1t,
TIM_TimerMode_t mode,
uint16_t frequency,
HAL_State_t intState,
EXTI_IntPriority_t intPriority);
void TIM_Timer1_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency);
/***************************** /
@ -92,7 +83,7 @@ void TIM_Timer1_Config(
// Timer2 Prescaler: [0, 255]
#define TIM_Timer2_SetPreScaler(__PRE__) do{P_SW2 = 0x80; TM2PS = (__PRE__); P_SW2 = 0x00;}while(0)
void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState);
void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency);
/***************************** /

View File

@ -30,6 +30,14 @@ typedef enum
UART1_BaudSource_Timer2 = 0x01,
} UART1_BaudSource_t;
typedef enum
{
UART1_AlterPort_P30_P31 = 0x00,
UART1_AlterPort_P36_P37 = 0x01,
UART1_AlterPort_P16_P17 = 0x10,
UART1_AlterPort_P43_P44 = 0x11,
} UART1_AlterPort_t;
#define UART1_SetRxState(__STATE__) SBIT_ASSIGN(REN, __STATE__)
#define UART1_ClearTxInterrupt SBIT_RESET(TI)
#define UART1_ClearRxInterrupt SBIT_RESET(RI)
@ -48,6 +56,10 @@ typedef enum
*/
#define UART1_ConfigMode2Fixed9bitUart(__STATE__) do{ SM0=1; SM1=0; SFR_ASSIGN(PCON, 7, __STATE__);}while(0)
#define UART1_SetTimer1Mode2Baudx2(__STATE__) SFR_ASSIGN(PCON, 7, __STATE__)
/**
* Alternative port selection: P30/P31, P36/P37, P16/P17, P43/P44
*/
#define UART1_SwitchPort(__ALTER_PORT__) (P_SW1 = P_SW1 & ~(0x03 << 6) | ((__ALTER_PORT__) << 6))
/**
* Mode1: 8-bit UART, dynamic baud-rate, provided by Timer1 or Timer2
*/

View File

@ -25,6 +25,6 @@ void UTIL_Uart1_33M1776_115200_Init(void);
void UTIL_Uart1_35M_9600_Init(void);
void UTIL_Uart1_36M864_9600_Init(void);
void UTIL_Uart1_36M864_115200_Init(void);
void UTIL_ItrimScan(uint8_t ircband, uint8_t *str);
// void UTIL_ItrimScan(uint8_t ircband, uint8_t *str);
#endif

View File

@ -18,16 +18,26 @@ static const uint16_t ticks_ms = (__CONF_FOSC / (float)1000 / 13 - 46);
static const uint8_t ticks_us = (__CONF_FOSC / (float)12100000UL);
static uint8_t clkdiv = 0x1;
void SYS_Init(void)
/**
* Change system clock
* - invoke this in the beginning of code
* - don't invoke this if the target frequency is already set by STC-ISP
*/
void SYS_SetClock(void)
{
if (__CONF_IRCBAND != 0x00 || __CONF_VRTRIM != 0x00 || __CONF_IRTRIM != 0x00)
uint16_t i = 0; uint8_t j = 5;
P_SW2 = 0x80;
if (CLKDIV != (__CONF_CLKDIV))
{
SYS_SetSysClkDiv(0);
SYS_SetFOSC(__CONF_IRCBAND, __CONF_VRTRIM, __CONF_IRTRIM, __CONF_LIRTRIM);
// Wait a while till sysclk stable, or it may block the main process
uint16_t i = ticks_ms;
CLKDIV = (__CONF_CLKDIV);
do { // Wait a while after clock changed, or it may block the main process
while (--i);
} while (--j);
}
P_SW2 = 0x00;
clkdiv = (__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV;
SYS_SetFOSC(__CONF_IRCBAND, __CONF_VRTRIM, __CONF_IRTRIM, __CONF_LIRTRIM);
while (--i); // Wait
}
void SYS_Delay(uint16_t t)
@ -50,15 +60,7 @@ void SYS_DelayUs(uint16_t t)
} while (--t);
}
void SYS_SetSysClkDiv(uint8_t div)
{
P_SW2 = 0x80;
CLKDIV = div;
P_SW2 = 0x00;
clkdiv = (div == 0)? 1 : div;
}
uint32_t SYS_GetSysClk(void)
uint32_t SYS_GetSysClock(void)
{
return ((uint32_t)__CONF_FOSC) / clkdiv;
}

View File

@ -17,15 +17,15 @@
#include "fw_util.h"
/**
* Calculate the initial value of timer counter
* Calculate the initial value of Timer0 & Timer1 counter
* - If the frequency is too high, it will return the value of `limit`, so the timer
* will run in the highest frequency
* - If the frequency is too low, it will return 0, so the timer will run in the
* lowest possible frequency
*/
int16_t _TIM_InitValueCalculate(uint16_t frequency, HAL_State_t freq1t, uint16_t limit)
int16_t TIM_Timer0n1_CalculateInitValue(uint16_t frequency, HAL_State_t freq1t, uint16_t limit)
{
uint32_t value = SYS_GetSysClk();
uint32_t value = SYS_GetSysClock();
if (!freq1t)
value = value / 12;
value = value / frequency;
@ -35,58 +35,44 @@ int16_t _TIM_InitValueCalculate(uint16_t frequency, HAL_State_t freq1t, uint16_t
return limit - value;
}
void TIM_Timer0_Config(
HAL_State_t freq1t,
TIM_TimerMode_t mode,
uint16_t frequency,
HAL_State_t intState,
EXTI_IntPriority_t intPriority)
void TIM_Timer0_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency)
{
uint16_t init;
TIM_Timer0_Set1TMode(freq1t);
TIM_Timer0_SetMode(mode);
if (mode == TIM_TimerMode_8BitAuto)
{
init = _TIM_InitValueCalculate(frequency, freq1t, 0xFF);
init = TIM_Timer0n1_CalculateInitValue(frequency, freq1t, 0xFF);
TIM_Timer0_SetInitValue(init & 0xFF, init & 0xFF);
}
else
{
init = _TIM_InitValueCalculate(frequency, freq1t, 0xFFFF);
init = TIM_Timer0n1_CalculateInitValue(frequency, freq1t, 0xFFFF);
TIM_Timer0_SetInitValue(init >> 8, init & 0xFF);
}
EXTI_Timer0_SetIntState(intState);
EXTI_Timer0_SetIntPriority(intPriority);
}
void TIM_Timer1_Config(
HAL_State_t freq1t,
TIM_TimerMode_t mode,
uint16_t frequency,
HAL_State_t intState,
EXTI_IntPriority_t intPriority)
void TIM_Timer1_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency)
{
uint16_t init;
TIM_Timer1_Set1TMode(freq1t);
TIM_Timer1_SetMode(mode);
if (mode == TIM_TimerMode_8BitAuto)
{
init = _TIM_InitValueCalculate(frequency, freq1t, 0xFF);
init = TIM_Timer0n1_CalculateInitValue(frequency, freq1t, 0xFF);
TIM_Timer1_SetInitValue(init & 0xFF, init & 0xFF);
}
else
{
init = _TIM_InitValueCalculate(frequency, freq1t, 0xFFFF);
init = TIM_Timer0n1_CalculateInitValue(frequency, freq1t, 0xFF);
TIM_Timer1_SetInitValue(init >> 8, init & 0xFF);
}
EXTI_Timer1_SetIntState(intState);
EXTI_Timer1_SetIntPriority(intPriority);
}
int16_t _TIM_Timer234_InitValueCalculate(
uint16_t frequency, uint8_t prescaler, HAL_State_t freq1t)
{
uint32_t value = SYS_GetSysClk();
uint32_t value = SYS_GetSysClock();
if (!freq1t)
value = value / 12;
value = value / ((prescaler + 1) * frequency);
@ -104,14 +90,12 @@ int16_t _TIM_Timer234_InitValueCalculate(
* 2. frequency = SYSCLK / (TMxPS + 1) / (0xFFFF - TxH,TxL) / (1T? 1 : 12)
*/
void TIM_Timer2_Config(
HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState)
void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency)
{
uint16_t init = _TIM_Timer234_InitValueCalculate(frequency, prescaler, freq1t);
TIM_Timer2_Set1TMode(freq1t);
TIM_Timer2_SetPreScaler(prescaler);
TIM_Timer2_SetInitValue(init >> 8, init & 0xFF);
EXTI_Timer2_SetIntState(intState);
}
void TIM_Timer3_Config(

View File

@ -25,7 +25,7 @@ __bit busy;
*/
int16_t _UART1_Timer_InitValueCalculate(HAL_State_t freq1t, uint32_t baudrate)
{
uint32_t value, sysclk = SYS_GetSysClk();
uint32_t value, sysclk = SYS_GetSysClock();
value = sysclk / (4 * baudrate);
if (!freq1t)
value = value / 12;

View File

@ -100,6 +100,7 @@ void UTIL_Uart1_36M864_115200_Init(void)
TR1 = 1;
}
/*
void UTIL_ItrimScan(uint8_t ircband, uint8_t *str)
{
uint8_t i = 0xFF, j;
@ -114,14 +115,14 @@ void UTIL_ItrimScan(uint8_t ircband, uint8_t *str)
{
SYS_SetFOSC(ircband, 0, i, j);
SYS_Delay(1);
// UTIL_PrintHex(IRCBAND);
// UTIL_PrintChar(' ');
// UTIL_PrintHex(IRTRIM);
// UTIL_PrintChar(0x20);
// UTIL_PrintHex(LIRTRIM);
// UTIL_PrintChar(0x20);
// UTIL_PrintString(str);
UTIL_PrintHex(IRCBAND);
UTIL_PrintChar(' ');
UTIL_PrintHex(IRTRIM);
UTIL_PrintChar(0x20);
UTIL_PrintHex(LIRTRIM);
UTIL_PrintChar(0x20);
UTIL_PrintString(str);
SYS_Delay(5);
} while (j--);
} while (i--);
}
}*/