Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4747

Program works!, however dont understand some DT-INT stuff.

$
0
0
Using a 18F4550 with internal default OSC. I started by using Darrel's INTs using the blinking LED program that worked, changing
T1CON = $31 was about 2 seconds between blinks so I tried
$01 that set it to about 2hz
$11 set it to about 1hz
$00 did nothing nor did $31, $10, $20

now on his Timer template page he has T1CON's listed as whole numbers 00, 10, 20, 30. I tryed these and program compiled but didnt run. This could be from me not specifying frequency, prescaler etc.. Im happy with the results so far, and right now I am just going to be using either 1 timer or 1 INT and 1 timer. I currently dont have to set it to run at a particular frequency so Im not studying that timer template page so much as the led blinky page and the Hello world page. I would like to know where to find a listing where the $31 came from? is there a chart or a rule for generating this number?

Ive created a new file to test my EEPROM animations and it works great, what it does is store 64 Custom characters (8 Characters x 8 Frames) and it load them to CGRAM on the LCD and animate them, it allows for 8 Animated characters on the screen at the same time! What I am going to post is the primer on this, anyone should be able to expand it however they want, i will only be using a Single animated character with 7 frames to keep it simple.

This Program will place a animated battery being charged whereever you want to place the 0 Character in CGRAM "LCDOUT 0"

Code:

Include "LCD_D.bas"  ' Defines for LCD using PORTD
INCLUDE "ADC_Default.bas" ' Defines for the ADC System
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
EEPROM 0,[14,17,17,17,17,17,17,31]  ' Cust Char #0
EEPROM 8,[14,17,17,17,17,17,31,31]  ' Cust Char #1
EEPROM 16,[14,17,17,17,17,31,31,31]  ' Cust Char #2
EEPROM 24,[14,17,17,17,31,31,31,31]  ' Cust Char #3
EEPROM 32,[14,17,17,31,31,31,31,31]  ' Cust Char #4
EEPROM 40,[14,17,31,31,31,31,31,31]  ' Cust Char #5
EEPROM 48,[14,31,31,31,31,31,31,31]  ' Cust Char #6
CGLOAD VAR WORD : CGLOAD = 0 ' Variable for holding Character # to Load
CGLLOC VAR BYTE : CGLLOC = 0 ' LCD Location to Store Character (0 to 7)
CGLOOP VAR BYTE    ' Variable for Selecting Data Bits
CGDATA VAR BYTE    ' Variable to Hold Character Data
Position Var WORD : Position = 0' Animation Frame
LCDOUT $FE, 2
Pause 1000
ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler  TMR1_INT,  _Animation1,  PBP,  yes
    endm
    INT_CREATE              ; Creates the interrupt processor
ENDASM
T1CON = $11                ; 01=.5s, 11=1s
@ INT_ENABLE  TMR1_INT    ; enable Timer 1 interrupts
Main:
LCDOUT 0
PAUSE 500
GOTO Main
'---[TMR1 - interrupt handler]--------------------------------------------------
Animation1:
CGLOAD = Position * 8 ' Converts your Character Selection to EEPROM Address
CGLLOC = 64  ' Converts LCD Slot to LCD Memory Address
LCDOUT $FE, CGLLOC
FOR CGLOOP = CGLOAD to (CGLOAD + 7)  'Sets 1st Memory Address to Read + Next 7
read CGLOOP, CGDATA ' Retrieve byte from EEPROM
LCDOUT CGDATA
next CGLOOP
position = position + 1
if position > 6 then position = 0
@ INT_RETURN

With some basic modifications you should be able to add up to 8 animated characters that are animated even if not being displayed onscreen. this is just an example program to simulate a battery charging icon on a LCD. feel free to let me know if you see something that can be shortened and if you can solve any of my questions at the top.

Viewing all articles
Browse latest Browse all 4747

Trending Articles