|
#91
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
While we're looking at the new code, what is the difference between interrupts 1,2 and 3-6? I read the encoders readme, and I understand how they differ. However, I haven't seen any documentation about the interrupts themselves. Could you please explain me how (if it all) they differ? |
|
#92
|
|||||
|
|||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Digital inputs 3-6 all go together to a third interrupt circuit, and automatically cause an interrupt on any input transition. There's only one flag to say that "something changed" on those pins. In order to determine which of the four inputs is responsible, the software has to do its own bookkeeping to compare the previous input state against the present one. That's a simple explanation. There's more detail in the PIC manual if you want it. |
|
#93
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
|
|
#94
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Quote:
Quote:
-Kevin |
|
#95
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Thanks for the link to Microchip. I went there three times and couldn't find it. The page looked like a sales page so I didn't scroll down and see the download links. Oh well. I've got it now.
|
|
#96
|
|||||
|
|||||
|
Re: New C18 3.0+ Compatible FRC Code
Thank you Kevin for all of your hard work! I like what I see so far and I can assure you that team 34 will put this to good use. |
|
#97
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Kevin:
Here are some change that I made to your serial routine to set the baudrate correctly for any processor speed. in serial_port.c #ifdef ENABLE_SERIAL_PORT_ONE void Init_Serial_Port_One(void) { // Start by initializing the serial port with code // common to receive and transmit functions // SPBRG = BAUD_38400 ; // baud rate generator register [251] SPBRG = SPBRG_VAL_1; // defined in hardware.h // #ifdef USART1_USE_BRGH_LOW TXSTAbits.BRGH = 0; // high baud rate select bit (asynchronous mode only) [248] #else // 0: low speed TXSTAbits.BRGH = 1; // high baud rate select bit (asynchronous mode only) [248] // 1: high speed #endif // 1: high speed .................................................. .................................................. .................................................. ...... #ifdef ENABLE_SERIAL_PORT_TWO void Init_Serial_Port_Two(void) { // Start by initializing the serial port with code // common to receive and transmit functions // SPBRG2 = BAUD_9600; // baud rate generator register [251] SPBRG2 = SPBRG_VAL_2; // defined in hardware.h // #ifdef USART2_USE_BRGH_LOW TXSTA2bits.BRGH = 0; // high baud rate select bit (asynchronous mode only) [248] #else // 0: low speed TXSTA2bits.BRGH = 1; // high baud rate select bit (asynchronous mode only) [248] // 1: high speed #endif // 1: high speed ------------------------------------------------------------------------------------------------------------------------------------------------------------ in the hardware set up routines... // Define system xtal/clock frequency // #define CLOCK_FREQ (40000000) // Frequency in Hz #if defined(__18CXX) // All PIC18 processors #include <p18cxxx.h> #define INSTR_FREQ (CLOCK_FREQ/4) // PIC18 clock divider #else #error Unknown processor or processor not defined #endif // Set up serial port(s) baud rate // #define BAUD_RATE_1 (38400) // Serial port 1, bps #define BAUD_RATE_2 (38400) // Serial Port 2, bps // set as needed... //#define USART1_USE_BRGH_LOW // for most lower baud rates //#define USART2_USE_BRGH_LOW // for most lower baud rates #if defined(USART1_USE_BRGH_LOW) #define SPBRG_VAL_1 ( ((CLOCK_FREQ/BAUD_RATE_1)/64) - 1) #else #define SPBRG_VAL_1 ( ((CLOCK_FREQ/BAUD_RATE_1)/16) - 1) #endif #if defined(USART2_USE_BRGH_LOW) #define SPBRG_VAL_2 ( ((CLOCK_FREQ/BAUD_RATE_2)/64) - 1) #else #define SPBRG_VAL_2 ( ((CLOCK_FREQ/BAUD_RATE_2)/16) - 1) #endif #if ((SPBRG_VAL_1 > 255) || (SPBRG_VAL_2 > 255)) #error "Calculated SPBRG value is out of range for current CLOCK_FREQ." #endif Last edited by Lafleur : 04-01-2008 at 11:14. |
|
#98
|
|||
|
|||
|
To be clear, without Kevin this would be miserable. Team 1622 is massively
in your debt. Thank you. For those who have not already installed the MCC upgrade, make sure you put it in the same directory with the upgraded MPLAB 8.0. Otherwise the linker can't find the libraries. I know by the trying it the wrong way. |
|
#99
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Rookie team 2605 will be using your code, it is structured in a way that makes more sense, I have not gone through it all the way yet, but so far so good. BTW is there a better search tool in mplab than the just straight basic find? For my embedded systems work I am always using grep and regexps, so far mplab has been really disappointing.
|
|
#100
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Comphappy,
The answer maybe Yes! Try under the Project Menu > Find in Project Files. Once you enter your keyword you'll be able to see the results in the output window under the find in files tab. Double click on whatever you want to see and a new window will open with a pointer to your chosen element. I hope this answers your question, as I'm not really sure as to what grep would deliver as a result. |
|
#101
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Thanks that is what I was looking for, still not very good, but better then what I had found. Grep is extreamly flexible long as you are willing to spend the time to learn how to use it correctly.
|
|
#102
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
Here's a snapshot of the latest build:
http://kevin.org/frc/ifi_frc_beta_3.zip http://kevin.org/frc/ifi_frc_gyro_beta.zip (with integrated ADC and Gyro code) -Kevin |
|
#103
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Kevin,
Is there any change log? So we can keep track of what's bew in beta 3? Other than, of course, the ADC and gyro in that version. Thanks. |
|
#104
|
||||
|
||||
|
Re: New C18 3.0+ Compatible FRC Code
I know MPLAB can generate a makefile for you but those always seem messy so I wrote up a quick one to use for myself with Kevin's new code. Figured I'd share it here in case anyone else finds it useful.
Code:
# Makefile for Kevin Watson's (http://kevin.org) C18 3.0 compatible FRC code
CC = C:\\mcc18\\bin\\mcc18.exe
CFLAGS = -p=18F8722 -k -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
LD = C:\\mcc18\\bin\\mplink.exe
LDFLAGS = 18f8722.lkr
LIBS = ifi_frc_8722.lib
LIBPATH = C:\\mcc18\\lib
MAP = ifi_frc.map
RM = del
SOURCES = autonomous.c disabled.c ifi_code.c ifi_frc.c interrupts.c pwm.c \
serial_ports.c teleop.c timers.c
OBJECTS = $(SOURCES:.c=.o)
EXECUTABLE = ifi_frc
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(LD) /l"$(LIBPATH)" $(LDFLAGS) $(OBJECTS) $(LIBS) /m"$(MAP)" /w /o"$(EXECUTABLE).cof"
.c.o:
$(CC) $< -fo="$@" $(CFLAGS)
clean:
$(RM) $(OBJECTS) $(EXECUTABLE).cof $(EXECUTABLE).hex $(MAP)
Last edited by jtdowney : 05-01-2008 at 08:05. Reason: mp2hex is ran automatically by the linker so it isn't needed |
|
#105
|
|||
|
|||
|
Re: New C18 3.0+ Compatible FRC Code
Forgive my noobiness, but is that makefile what I need to develop on ubuntu? Set up c18 in wine, put the file in the directory with the code and do a make? Will that give me a loadable hex file? There was another makefile posted earlier that looked like it was made for Linux, should I use that?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does the camera code suits to all versions of MPLAB and C18? | razer | Programming | 3 | 04-01-2007 14:50 |
| Trying to follow C18 interrupt context code... | dcbrown | Programming | 5 | 21-12-2006 09:01 |
| Error w/ FRC code | JamesBrown | Programming | 2 | 08-01-2005 16:17 |
| Programming code Fix FRC | Ferazel2001 | Programming | 6 | 08-02-2004 02:46 |
| FRC default code | hedgehogger | Programming | 2 | 21-01-2004 18:41 |