|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Programming a 2nd PIC
In order to easily handle the analysis of PWM signal input I'm using a second PIC (PIC18F452) to do the calculation and plan on using the RC as the Master device where the two PICs communicate through the TTL serial line on the RC and a serial port on the demo board (PICDEM 2 Plus demonstration board from Microchip). I have a question about the programming of the 2nd PIC. Since both 40 pin PIC's are of the PIC18Fxx2 family their pin configuration and registers associated with each are the same. Does this then make it possible to transport the code that I had working on the RC to this 2nd PIC directly? Or do I have to completely rewrite my own code?
(Essentially I don't know what's in that RC box and if there is more to it then just a PIC and tracks that attach the pins to the headers for signal input on the outside) Any advice would be greatly appreciated |
|
#2
|
|||
|
|||
|
Re: Programming a 2nd PIC
Quote:
|
|
#3
|
||||
|
||||
|
Re: Programming a 2nd PIC
The two PICs in the RC are 18F8520 80-pin devices The Microchip C18 compiler can build for the 452's so the code that does your calculation shouldn't have to be rewritten (if it's in C). You will need to create a new project in MPLAB from scratch and use a linker file for the 452 instead of the 8520. There is no need to include RC specific code in your new project, but you may want to look at ifi_aliases.h and ifi_picdefs.h to get an idea of how to define aliases for the hardware registers. Keep in mind that the 452 doesn't have all of the hardware that the 8520 has, so you may want to look at the 452's spec sheet to make sure you haven't aliased a register that doesn't exist. You can reuse some of the IFI code, like the serial driver, this may save you some time in getting you project up and running.
|
|
#4
|
|||
|
|||
|
Re: Programming a 2nd PIC
I knew you would be back on line asking for help with the pic demo board. First, unless I missed something, the demo board doesn't support in circuit programming. I believe you have to use a separate chip programmer. This means that you have to pop the processor out- program it- pop it back in - test - pop it out- reprogram - pop it in - test. This isn't very productive.
Second, using the pic compiler and IDE provide allot of power, but add complexity to the proto typing effort. There is allot of initializing that has to be done for both the processor, C compiler, linker and assembler. IFI has done this for us. You'll have to duplicate it and strip out the stuff they set up for the dual processor. Third, if your using the free software from microchip , the optimizer is left out. Your code will take more memory in most cases. If you use the IFI provided software, they had it customized for the IFI controller. Don't Know if it affects working with other chips. There are other options out there that might be better for experimentation and proto typing. What worked for me is the Kronos robotic dios chip and a work board http://www.kronosrobotics.com/xcart/...52&cat=0&page= http://www.kronosrobotics.com/xcart/...68&cat=0&page= The work board has a solderless bread board for proto typing. The Dios chip is the same chip your using only it has a powerful basic interpreter on it. They have examples on site for sonar sensors, Sharp IR senors, digital compasses, serial communications, PWM, quadrature, timers, etc. Allot of work has been done for you. You can make a program change and 3 seconds later your code is running. I've used this set up with some students that just couldn't get started this year with programming on our team. I spent a couple hours with them and this setup. They're off and running teaching me now. |
|
#5
|
|||
|
|||
|
Re: Programming a 2nd PIC
the demo board supports programming through the mplab ICD2 through an rj-11 plug on the board. and yea, i quickly became aware of how i had to rewrite the start up, pic def, and alias file myself. Which i have no problem doing excpet for the fact that I seriously got lost in the pic def file. They're defnining things in structs that I can't find anywhere on the data sheet (ie the following)
Code:
extern volatile near unsigned char RCSTA2;
extern volatile near union {
struct {
unsigned RX9D:1;
unsigned OERR:1;
unsigned FERR:1;
unsigned ADEN:1;
unsigned CREN:1;
unsigned SREN:1;
unsigned RX9:1;
unsigned SPEN:1;
};
struct {
unsigned RCD8:1;
unsigned :5;
unsigned RC9:1;
};
struct {
unsigned :6;
unsigned NOT_RC8:1;
};
struct {
unsigned :6;
unsigned RC8_9:1;
};
} RCSTA2bits;
maybe i'm approaching this totally wrong any advice? |
|
#6
|
|||
|
|||
|
Re: Programming a 2nd PIC
thanks for the advice on that other prototyping board, it sounds extremely useful
|
|
#7
|
||||
|
||||
|
Re: Programming a 2nd PIC
Quote:
-Kevin |
|
#8
|
||||
|
||||
|
Re: Programming a 2nd PIC
I believe RCD8:1 means RCD8 is defined as an alias for the first bit of the structure, and the :5 is a placeholder so the next 5 bits are not aliased as anything, and then RC9 is defined as an alias for the 7th bit of the structure.
|
|
#9
|
|||
|
|||
|
Re: Programming a 2nd PIC
wow, so that .h file just saved me 3 days
thanks for the heads up on that. that's exactly what i needed |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VEX programming | Gene F | Programming | 14 | 08-08-2006 22:21 |
| Organizing a programming team. | scitobor 617 | Programming | 7 | 28-01-2005 19:18 |
| 'Fix It Window' and Programming.... | JMac | Programming | 19 | 25-01-2005 18:57 |
| Programming and Electronics — Getting Started | Sidney San Martín | Technical Discussion | 7 | 12-01-2005 15:25 |
| pic: Match 0105: 2nd highest score in the nation | CD47-Bot | Extra Discussion | 6 | 31-03-2003 11:14 |