This file is part of SimpleRTOS2
/*============================================================================*/ /* SimpleRTOS - Very simple RTOS for Microcontrollers - PIC32 port v2.00 (2014-01-21) isaacbavaresco@yahoo.com.br */ /*============================================================================*/ /* Copyright (c) 2007-2014, Isaac Marino Bavaresco All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*============================================================================*/ /* Set TAB width to 4 characters */ /*============================================================================*/ /* PIC32MX210F016B +-------------U-------------+ | | ==| 1 !MCLR AVCC 28 |== | | SPI1_SS <- ==| 2 RA0 AGND 27 |== | | SPI1_SDI -> ==| 3 RA1 RB15 26 |== <- SPI2_SCK | | PGED -> ==| 4 RB0 RB14 25 |== -> SPI1_SCK | | PGEC -> ==| 5 RB1 RB13 24 |== <- ANALOG_AN11 | | RS232_U1RX -> ==| 6 RB2 VUSB3V3 23 |== | | RS232_U1TX <- ==| 7 RB3 RB11 22 |== <-> UBS_D- | | ==| 8 GND RB10 21 |== <-> UBS_D+ | | ==| 9 RA2/OSC1 VCAP 20 |== | | ==| 10 RA3/OSC2 GND 19 |== | | RST <- ==| 11 RB4 RB9 18 |== <-> SPI2_SS/TX/SDA | | SPI2_MISO_2 -> ==| 12 RA4 RB8 17 |== <-> SPI2_SDO/RX/SCL | | ==| 13 VCC RB7 16 |== -> IRQ | | SPI1_SDO <- ==| 14 RB5 VBUS 15 |== <- 5V | | +---------------------------+ */ /*============================================================================*/ #include <p32xxxx.h> #include <plib.h> #include <string.h> #include "../SimpleRTOS/SimpleRTOS.h" #include "../SimpleRTOS/SerialPIC32MX.h" #include "Test.h" /*============================================================================*/ #define CLOCK 20000000ul #define BAUD_RATE 19200ul #define TICK_RATE 1000ul #define COUNTER_RATE 100ul /*============================================================================*/ void MainTask( void* ); /*============================================================================*/ unsigned char Stacks[6][STACK_SIZE]; context_t Contexts[6]; /* We will have a maximum of 6 simultaneously running tasks. */ /*============================================================================*/ int i, j, k, l; int aa, bb; void T1( void *param ) { aa = (int)param; k = 0; while( 1 ) { for( i = 0; i < 3599; i++ ) k++; Yield(); } } /*============================================================================*/ void T2( void *param ) { bb = (int)param; l = 0; while( 1 ) { for( j = 0; j < 3599; j++ ) l++; Yield(); } } /*============================================================================*/ int main( void ) { int i; #if 0 PORTA = 0x00; /* All PORTA pins off. */ PORTB = 0x06; TRISA = 0xe0; TRISB = 0x02; #endif for( i = 0; i < sizeof Stacks / sizeof Stacks[0]; i++ ) memset( Stacks[i], 'A' + i, sizeof Stacks[i] ); /* Initialize the contexts and the rest of the RTOS. */ InitRTOS( Contexts, sizeof Contexts / sizeof Contexts[0] ); /* Create just one task, it will create the others. */ CreateTask( Stacks[0], sizeof Stacks[0], NULL, GetAddress( MainTask ), 0 ); /* CreateTask( Stacks[0], sizeof Stacks[0], (void*)1, GetAddress( T1 ), 0 ); CreateTask( Stacks[1], sizeof Stacks[1], (void*)2, GetAddress( T2 ), 0 ); */ /* WARNING: due to a bug (whether in the debuggers or in the silicon, I don't know), the freeze timers in debug mode cannot be set in program. To be able to debug follow the procedure below: If using PICKit3 or ICD3 as debugger, put a breakpoint on the "StartRTOS" statement below and run the program. Before continuing with the debugging, using the watch window set both T1CON and T2CON to the value 0x0004000. */ /* From now, the RTOS will take over. */ StartRTOS( 40000 ); return 0; } /*============================================================================*/
file: /Techref/member/IMB-yahoo-J86/TestMain-PIC32MX.c.htm, 7KB, , updated: 2014/2/16 03:49, local time: 2024/12/28 10:03,
owner: IMB-yahoo-J86,
3.144.227.73:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/Techref/member/IMB-yahoo-J86/TestMain-PIC32MX.c.htm"> A simple RTOS for microcontrollers based upon concepts of FreeRTOS</A> |
Did you find what you needed? |