summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-03-24 22:33:47 +0100
committerAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-03-24 22:33:47 +0100
commitf50582d2c236876f9b551864ee8ff201aa03f13b (patch)
tree9851de2deb6a19691a22108015d0b29a000bfad2
parent73d63aa441a2d8b950b9f132b91f9b0329de1c78 (diff)
downloadfreertos-f50582d2c236876f9b551864ee8ff201aa03f13b.tar.gz
freertos-f50582d2c236876f9b551864ee8ff201aa03f13b.tar.bz2
freertos-f50582d2c236876f9b551864ee8ff201aa03f13b.tar.xz
Setup TMR0 to correctly generate ticks upon configTICK_RATE_HZ value
-rw-r--r--Demo/PIC18_SDCC/FreeRTOSConfig.h12
-rw-r--r--Demo/PIC18_SDCC/Makefile8
-rw-r--r--Demo/PIC18_SDCC/main.c2
-rw-r--r--Source/portable/SDCC/PIC18/port.c18
-rw-r--r--Source/portable/SDCC/PIC18/portmacro.h3
5 files changed, 23 insertions, 20 deletions
diff --git a/Demo/PIC18_SDCC/FreeRTOSConfig.h b/Demo/PIC18_SDCC/FreeRTOSConfig.h
index ce6dec9c..be910a44 100644
--- a/Demo/PIC18_SDCC/FreeRTOSConfig.h
+++ b/Demo/PIC18_SDCC/FreeRTOSConfig.h
@@ -1,7 +1,7 @@
/**
-* ###################################################################################
+* #######################################################################################
* Gaye Abdoulaye, <walsimou@walsimou.com>
-* Copyright (C) 2009 Gaye Abdoulaye, <walsimou@walsimou.com>. All rights reserved.
+* Copyright(C) 2009 GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>. All rights reserved.
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License
@@ -15,14 +15,14 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
-* ###################################################################################
+* #######################################################################################
*
* \file FreeRTOSConfig.h
* \brief FreeRTOSConfig.h for SDCC PIC18 (pic16 arch in sddc world) port.
* \brief It is based on other PIC18 port.
-* \author Gaye Abdoulaye, <walsimou@walsimou.com>
+* \author GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
* \date february 2009
-* ###################################################################################
+* #######################################################################################
*/
#ifndef FREERTOS_CONFIG_H
@@ -31,7 +31,7 @@
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
-#define configTICK_RATE_HZ ((portTickType)9766)
+#define configTICK_RATE_HZ ((portTickType)1000)
#define configCPU_CLOCK_HZ ((unsigned portLONG)20000000)
#define configMAX_PRIORITIES ((unsigned portBASE_TYPE)5)
/*Since in main.c we define a hardwre stack to be 64bytes in size,
diff --git a/Demo/PIC18_SDCC/Makefile b/Demo/PIC18_SDCC/Makefile
index 1b0ea5e2..488c64c3 100644
--- a/Demo/PIC18_SDCC/Makefile
+++ b/Demo/PIC18_SDCC/Makefile
@@ -1,6 +1,6 @@
-###################################################################################
-# Gaye Abdoulaye, <walsimou@walsimou.com>
-# Copyright (C) 2009 Gaye Abdoulaye, <walsimou@walsimou.com> All rights reserved.
+#########################################################################################
+# GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
+# Copyright(C) 2009 GAYE Abdoulaye Walsimou, <walsimou@walsimou.com> All rights reserved.
#
# This program is free software; you can distribute it and/or modify it
# under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
#
# \file Makefile
# \brief Makefile of root project
-# \author Gaye Abdoulaye, <walsimou@walsimou.com>
+# \author GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# \date February 2009
###################################################################################
diff --git a/Demo/PIC18_SDCC/main.c b/Demo/PIC18_SDCC/main.c
index 6d12f4cb..729101c9 100644
--- a/Demo/PIC18_SDCC/main.c
+++ b/Demo/PIC18_SDCC/main.c
@@ -1,7 +1,7 @@
/**
* #######################################################################################
* GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
-* Copyright(C) 2009 Gaye Abdoulaye Walsimou, <walsimou@walsimou.com>. All rights reserved.
+* Copyright(C) 2009 GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>. All rights reserved.
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License
diff --git a/Source/portable/SDCC/PIC18/port.c b/Source/portable/SDCC/PIC18/port.c
index 86c52bad..7bdf0fef 100644
--- a/Source/portable/SDCC/PIC18/port.c
+++ b/Source/portable/SDCC/PIC18/port.c
@@ -83,9 +83,9 @@ static void prvSetupTimerInterrupt(void);
* When MR0ReloadValue=0 (65536 increments) configTICK_RATE_HZ=76Hz (with respect to values in FreeRTOSConfig.h)
* When MR0ReloadValue=65535 (1 increment) configTICK_RATE_HZ=5MHz (with respect to values in FreeRTOSConfig.h)
* This implies the bellow linear relation between configTICK_RATE_HZ and TMR0ReloadValue
- * , if we accept that 1 is negligible with respect to 65535.
+ * TMR0ReloadValue=65536 - configCPU_CLOCK_HZ/(portTIMER_FOSC_SCALE*configTICK_RATE_HZ)
*/
-portSHORT TMR0ReloadValue=(portSHORT)(65536.0 -(float)(portTIMER_FOSC_SCALE*65536.0*configTICK_RATE_HZ/configCPU_CLOCK_HZ)+65537.0);
+const unsigned portSHORT TMR0ReloadValue=(65536 - configCPU_CLOCK_HZ/(configTICK_RATE_HZ*portTIMER_FOSC_SCALE));
/*
@@ -202,7 +202,7 @@ portBASE_TYPE xPortStartScheduler(void)
/* Restore the context of the first task to run. */
portRESTORE_CONTEXT();
- /* Should not get here. Use the function name to stop compiler warnings. */
+ /* Should not get here. Use the function name to stop compiler warnings. */
( void ) prvLowInterrupt;
return pdTRUE;
@@ -254,7 +254,11 @@ void vPortYield(void) __naked
/* Interrupts must have been enabled for the ISR to fire, so we have to
save the context with interrupts enabled. */
portSAVE_CONTEXT(portGLOBAL_INTERRUPT_FLAG);
+
INTCONbits.TMR0IF=0;
+ /*set TMR0L and TMR0H vlaue*/
+ TMR0H=(unsigned portCHAR)((TMR0ReloadValue&(unsigned portSHORT)0xff00)>>8);
+ TMR0L=(unsigned portCHAR)(TMR0ReloadValue&(unsigned portSHORT)0x00ff);
/* Maintain the tick count. */
vTaskIncrementTick();
@@ -283,15 +287,13 @@ static void prvSetupTimerInterrupt(void)
INTCONbits.TMR0IF=0; /*Timer0 interrupt flag cleared*/
INTCON2bits.T0IP=0; /*TimerO has low priority interrupt*/
- /**/
- TMR0H=0x00; /*Initialize timer0 high byte register*/
- TMR0L=0x00; /*Initialize timer0 low byte register*/
-
+ /*set TMR0L and TMR0H vlaue*/
+ TMR0H=(unsigned portCHAR)((TMR0ReloadValue&(unsigned portSHORT)0xff00)>>8);
+ TMR0L=(unsigned portCHAR)(TMR0ReloadValue&(unsigned portSHORT)0x00ff);
RCONbits.IPEN=1; /* Interrupt priority feature enabled. FIXME: this is
* something like hardware interrupt controller configu-
* ration, so needs to be done somewhere else I think
*/
-
T0CONbits.TMR0ON=1; /*Now enable timer0*/
}
diff --git a/Source/portable/SDCC/PIC18/portmacro.h b/Source/portable/SDCC/PIC18/portmacro.h
index 48e8ad2d..013eb01a 100644
--- a/Source/portable/SDCC/PIC18/portmacro.h
+++ b/Source/portable/SDCC/PIC18/portmacro.h
@@ -1,7 +1,7 @@
/**
* #######################################################################################
* GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
-* Copyright (C) 2009 Gaye Abdoulaye, <walsimou@walsimou.com>. All rights reserved.
+* Copyright(C) 2009 GAYE Abdoulaye walsimou, <walsimou@walsimou.com>. All rights reserved.
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License
@@ -29,6 +29,7 @@
#define PORTMACRO_H
#include <pic18fregs.h>
+#include <math.h>
/*-----------------------------------------------------------
* Port specific definitions.