Moderator: ericb

...
#define LED_GRN_TOG (GreenLED_Data_ADDR ^= GreenLED_MASK)
...
CYFISNP_TimeSet(&ledTimer, LED_BLINK_TIME);
...
while(1){
if (CYFISNP_TimeExpired(&ledTimer)) {
LED_GRN_TOG;
CYFISNP_TimeSet(&ledTimer, LED_BLINK_TIME);
}
}
WORD ledTimer;#define LED_BLINK_TIME (1000 / CYFISNP_TIMER_UNITS)




#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
void Timer8_ISR(void);
void LED_On(void);
#pragma interrupt_handler Timer8_ISR
unsigned char tflag = 0;
unsigned char counter = 0;
void Timer8_ISR(void)
{
tflag = 1;
return;
}
int counter;
counter++;
void LED_On(void)
{
LED_1_Invert();
}
void main (void)
{
Timer8_WritePeriod(10);
Timer8_WriteCompareValue(0x00);
M8C_EnableGInt;
Timer8_EnableInt();
Timer8_Start();
for (;;) {
if ( tflag) {
counter++;
if ( counter == 100 ) {
LED_On();
counter = 0;
}
tflag = 0;
}
}
}



//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <stdlib.h>
void Timer8_ISR(void);
void LED_1_Invert( void );
int tflag = 0;
int counter = 1;
#pragma interrupt_handler Timer8_ISR
void Timer8_ISR(void)
{
tflag = 1;
return;
}
unsigned char prString[21];
void main (void) {
LCD_1_Start(); /* Init the LCD */
Timer8_1_WritePeriod(0xA);
Timer8_1_WriteCompareValue(0x00);
M8C_EnableGInt;
Timer8_1_EnableInt();
Timer8_1_Start();
LCD_1_Position( 0,0 );
LCD_1_PrCString( "Count" );
while(1) {
if ( tflag ) {
counter++;
itoa( prString, counter, 10 ); // Convert count to a char string
LCD_1_Position( 0,6 );
LCD_1_PrString( prString );
if ( counter == 100 ) {
LCD_1_Position( 0,0 );
LCD_1_PrCString( " " ); // Len of string should be # chars in LCD line
LED_1_Invert();
counter = 0;
}
tflag = 0;
}
}
}





SleepTimer_1_SLEEP_ISR_END:
;@PSoC_UserCode_BODY_1@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom assembly code below this banner
;---------------------------------------------------
; NOTE: interrupt service routines must preserve
; the values of the A and X CPU registers.
;---------------------------------------------------
; Insert your custom assembly code above this banner
;---------------------------------------------------
;---------------------------------------------------
; Insert a lcall to a C function below this banner
; and un-comment the lines between these banners
;---------------------------------------------------
;PRESERVE_CPU_CONTEXT
;lcall _My_C_Function
;RESTORE_CPU_CONTEXT
; if not saving/restoring context, use the ljmp...
;
ljmp _SleepTimer_1_ISRV
;---------------------------------------------------
; Insert a lcall to a C function above this banner
; and un-comment the lines between these banners
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
reti
; end of file SleepTimer_1INT.asm






Users browsing this forum: Majestic-12 [Bot] and 3 guests