Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About JimFranklin

  • Rank
  1. Hi Fyndor, When the interrupt occurs, the CPU will always jump to address 0x04, this is fixed by the chip and can't be changed, you could if you wanted to, jump from there to anywhere in the memory, but interrupts need to happen quickly so this isn't recommended. Once you are in the routine, it's advisable to save at least the STATUS and W registers, and retrieve them when you exit the interrupt service routine - after all, you can't be sure what was happening when the interrupt occurred (usually). When you are in th interrupt service routine, you can check the INTCON register (0x0B from any memory bank) to see what caused the interrupt. The main INTCON bits are: Bit 2 --- TMR0IF --- Timer 0 has overflowed - you must reset this yourself in the interrupt service routine. Bit 1 --- INTF --- RBO/INT external interrupt occurred - you must reset this yourself in the interrupt service routine. Bit 0 --- RBIF --- RB Port change interrupt - one of the portB bit 7.. Bit 4 lines has changed state (1 to 0 or 0 to 1) The other timers are set/checked in PIE1, PIR1. PIE2, PIR2, and PCON registers. ** NOTE ** Even if you don't have interrupts set, the registers above will have the flags set when something that would cause an interrupt (if they were enabled) happens. You will have to clear all of the interrupt flags before you enable interrupts, otherwise the PIc will think that everything has happened at once... A fully detailed description of the interrupt registers is in the PIC1687XA manual from microchip's website, but if you need more info, drop another message here. Regards Jim
  2. Hi Firstly, apologies for the length of this post. (I just previewed it!). I have a little project on the go, I have built the prototype based on a PIC16F877A with an LCD display amongst other things. I am writing a menu system for the software and have a flexible design idea but I am struggling with the C code. (I am a visual basic man - anyone offering to write a compiler for the PIC? OK as brief as I can. top menu has menu number 00, 10, 20, 30 and going right from 30 goes to menu 00 and left from 00 goes to 30. (a cylindrical effect). some menus go down, so 00 can go down to 01, and then down to 02. 01 goes left to 83 (an action) and right to 84 (an action). get the drift? I chose 8x for the actions so we can test bit 7. This limits us to 127 menus/submenus/actions. FF indicates no action. NOTE: Only left or right are used to run a process. and as we know all processes when designing this, we can use a switch statement to call the relevant process based on the number we grab from the table. OK I intend to store the configuration of the menu like this. menu, Up, Dn, Rt, Lt (current menu , up, down,right, left) e.g (all in hex .) 00 FF 01 10 30 <--- menu 00, no up, dn=01, rt=10, lt=30 01 00 02 83 84 <--- menu 01, up=00, dn=02, rt=83, lt=84 02 01 03 FF 85 <--- menu 02, up=01, dn=03, rt=none, lt=85 and so on. There will also be a menu string listing something like these with menu number, text, 0x00 to terminate. 00 Main 00 01 Config 00 02 Setup 00 03 Schedule 00 04 ..... FF 00 00 <-- end of menu I have written some pseudo code, and started the C, but I am struggling with how to setup the data stuff. Pseudo Code. 1. Set current menu=00 2. Load Menu data for current option (menu, up,dn,rt,lt) 3. Display menu text (name) and options for up, dn, rt, lt. 4. wait at step 4 until keypress (do interrupts as needed) 5. if option chosen is an FF function (none) goto 4. 6. if key=left or right and bit7 of option=1 call process listed 7. it wasn't an action, so get the new menu number and go to step no. 2 Any ideas. (incidentally if anyone is intested I am designing/writing a home control system, based on X10 and probably using some of their protocols. I will be publishing this all to the web as I go along) (Anyone want to join me on this project?). Regards Jim
  • Create New...