// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// configuration
#pragma*config OSC = INTIO2, WDT = OFF, LVP = OFF, PWRT = OFF, BOR = OFF, FSCM = OFF
#include <stdlib.h>
#include <p18f1320.h>
#include <usart.h>
#include <adc.h>
#include <delays.h>
#include <portb.h>
#include <timers.h>
// unsigned char config;
// unsigned int spbrg;
char str[8]="At Zero";
unsigned int tres;
int reslta0;
int reslts0;
char A1[5];
int reslta3;
int reslts3;
char B1[5];
void main(void)
{
OSCCON = 0x72;
// OSCCONbits.IRCF0=1;
// OSCCONbits.IRCF1=1;
// OSCCONbits.IRCF2=1; //set for 8Mhz
OpenTimer0( TIMER_INT_OFF &
T0_16BIT &
T0_SOURCE_INT &
T0_PS_1_256 );
while(1);
{
}
// while(ReadTimer0 !=0) ;
// {
// }
//
// putsUSART(str); //print string
}
I copied you code and created a project with it and the 18F1320i.lkr file. I did not see a problem on the simulator or the junebug.
Are you sure the chip is programming, try erasing it first.
void OpenTimer0(unsigned char config)
{
T0CON = (0x7f & config); // Configure timer, but don't start it yet
TMR0H = 0; // Reset Timer0 to 0x0000
TMR0L = 0;
INTCONbits.T0IF = 0; // Clear Timer0 overflow flag
if(config&0x80) // If interrupts enabled <-- looping
INTCONbits.T0IE = 1; // Enable Timer0 overflow interrupt
else
INTCONbits.T0IE = 0;
T0CONbits.TMR0ON = 1; <-- looping
}
#endif
// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// configuration
#pragma*config OSC = INTIO2, WDT = OFF, LVP = OFF, PWRT = OFF, BOR = OFF, FSCM = OFF
#include <stdlib.h>
#include <p18f1320.h>
#include <timers.h>
void main(void)
{
OSCCON = 0x72;
INTCONbits.T0IE = 0;
OpenTimer0(TIMER_INT_OFF &
T0_16BIT &
T0_SOURCE_INT &
T0_PS_1_1 );
while(1){
}
}
I ran the first code you posted with both the simulator and the junebug. Neither had the problem. There should be no problem with the CODE.
Try it on the junebug. Maybe the simulator is the problem in your case.
// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// configuration
#pragma*config OSC = INTIO2, WDT = OFF, LVP = OFF, PWRT = OFF, BOR = OFF, FSCM = OFF
#include <stdlib.h>
#include <stdio.h>
#include <p18f1320.h>
#include <p18cxxx.h>
#include <delays.h>
#include <timers.h>
void main(void)
{
TRISA = 0x00;
LATAbits.LATA0 = 0x01;
OSCCONbits.IRCF0=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF2=1; //set for 8Mhz
// OpenTimer1(TIMER_INT_OFF &
// T1_8BIT_RW &
// T1_SOURCE_INT &
// T1_PS_1_1 );
while(1){
LATAbits.LATA6 = 0x0;
LATAbits.LATA6 = 0x1;
}
}
t0arg = TIMER_INT_OFF &
T1_8BIT_RW &
T1_SOURCE_INT &
T1_PS_1_1 ;
OpenTimer0(t0arg);
// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// JuneBug Info
// Buttons RB0, RB2, RB5.
// Analog AN1, AN3
// IR RB0
// LED's RA0, RA6, RA7
//
// configuration
#pragma*config OSC = INTIO2, WDT = OFF, LVP = OFF, PWRT = OFF, BOR = OFF, FSCM = OFF
#include <p18f1320.h>
#include <timers.h>
void delay(long t)
{
int i;
do i = i *t;
while(--t);
}
void main(void)
{
char t0arg;
OSCCONbits.IRCF0=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF2=1; //set for 8Mhz
TRISA = 0x01;
LATAbits.LATA0 = 0x01;
t0arg = TIMER_INT_OFF &
T1_8BIT_RW &
T1_SOURCE_INT &
T1_PS_1_1 ;
OpenTimer0(t0arg);
while(1)
{
LATAbits.LATA6 = 0x0;
delay(10000);
LATAbits.LATA6 = 0x1;
delay(10000);
}
}
Timer1 has a setting that can cause the chip to be unusable (but fixable). Stay away from it until you are up to speed.
Again, I compiled your code and it works . I am attaching a hex file that you should be able to load and run. It is from the source provided here which is similar to yours execpt it blinks a LED on the Junebug. This source works even when the call to open_timer0 is enabled. (as did yours)
The hex file was changed from bnzr.hex to bnzr.hex.txt to get the fourm to attach it.
I hate to say this buy I suspect some form of operator error. Post the output from your build and PICkit2 windows. There has to be some problem. The source code is good.
3v0
OpenTimer1(TIMER_INT_OFF &
T1_8BIT_RW &
T1_SOURCE_INT &
[COLOR="Red"]T1_OSC1EN_OFF &[/COLOR]
T1_PS_1_1 );
Using timer1 flags for timer0 is my mixup. Binzer changed the call in his code from timer0 to timer1. I changed it back without changing the flags too. I knew I should have parsed the value but was too tired/lazy. It is about 2 AM here. But that is an excuse rather then a reasonYou are calling OpenTimer0 with Timer1 flags.
However, something strange is happening here, the value passed is indeed 0x0d and the first line of OpenTimer1 is T1CON = (0x7e & config); which sets bit 3 of T1CON and enables the timer1 oscillator.
Mike.
@Binzer
To fix the chip you need to erase it. Use the PICkit2 tool which lets you set the chip type manualy. (drop down box next to device). Then erase the chip a few times. It is sort of like herding pigs but after a a few tries I got MPLAB to read the correct ID.
I still want to see the output windows info from BUILD and PICkit2.
You need to use the Junebug and the PICkit2 software to erase the chip as I outlined the previous post. The config mem is currently programed so that MPLAB can not ID the chip.
Maybe you did this but let me go over it again.I did give that a shot. Pickit2 can see the 'Super Junebug' but not the target chip, tried doing an erase operation a bunch of times with no luck. I am wondering if the charge pump on the Junebug is working?
Going to take a look at it during lunch (7:00pm est).
Mike
I forgot to mention this
Prior to selecting the chip type in the PICkit2 software you have to do PROGRAMMER>MANUAL DEVICE SELECT
Then you can erase it. Once it is erased both MPLAB and PICkit2 software should be able to ID the chip correctly.
I installed the tools in the normal location and do not recall ever having to set any of the locations. Or are you talking about a user created lib ?
Are you using the wizzard to create new projects ?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?