Hi,
I have incorporated Jan's suggestions into the code, and apparently got the
same behaviour. Is it possible to get from you, Jan, the modified code that
you have for the PIC18F2220 as I try on that particular mcu? Attached to the
email is the code.
Cheers,
Stanley
On 10/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> Stanley Lee wrote:
> > Hi,
> >
> > Sorry for another email. I have received modified version of Jan's
> > makefile. The compilation and build process is solved. However, I am
> > encountering the same problem as I have experienced before, and that is
> > the PIC18F2620 doesn't execute the operation of blinking the LEDs
> > automatically right after external power is applied. I'm thinking of
> > trying the same code (except for some fusebits/hardware tweaks on a
> > PIC16F877A, PIC16F688, PIC16F690, or PIC16F628. Any suggestions if this
> > thought is a feasible alternative to sideline the development?
> >
>
> Checked your code on a testboard with a pic18f2220 (sorry, no
> oscilloscope here to test the blinking frequency) but they do blink here
> with a few changes/advises to your code:
>
> 1. Use unsigned int not int for your delay function.
> 2. i would add _PWRT_ON_2L when using the internal oscillator to give
> the osc a few steps to stabilize before executing first code.
> 3. You *need* to tell sdcc (someone correct me here if its wrong) where
> you want the stack to be. I usually put it onto gpr2 (or gpr1 for
> smaller devices, see lkr file for the address of the gpr(s)). For the
> pic18f2620 this would be
>
> #pragma stack 0x200 0xff /* (<- always first line in main.c) */
>
> somewhere at the start of the program. You will encounter non
> predictable errors/misbehavior if your forgot this and sdcc sadly
> doesn't warn you about it.
>
> 4. also the dly = dly; is not needed just add a ; after the while like
> void delay(unsigned int dly)
> {
> while(--dly > 0) ;
> }
>
> Now your programm runs fine.
>
> jan
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
#include "/usr/share/sdcc/include/pic16/pic18fregs.h"
// Stack initialization in GPR
#pragma stack 0x200 0xff
// Set the __CONFIG words:
code char at __CONFIG1H _conf0 = _OSC_INTIO7_1H;
code char at __CONFIG2L _conf1 = _BOREN_OFF_2L & _PWRT_ON_2L;
code char at __CONFIG2H _conf2 = _WDT_DISABLED_CONTROLLED_2H;
code char at __CONFIG3H _conf3 = _MCLRE_MCLR_OFF_RE3_ON_3H;
code char at __CONFIG4L _conf4 = _LVP_OFF_4L;
code char at __CONFIG5L _conf5 = _CP_0_OFF_5L & _CP_1_OFF_5L;
code char at __CONFIG5H _conf6 = _CPD_OFF_5H & _CPB_OFF_5H;
code char at __CONFIG6L _conf7 = _WRT_0_OFF_6L & _WRT_1_OFF_6L;
code char at __CONFIG6H _conf8 = _WRTD_OFF_6H & _WRTB_OFF_6H & _WRTC_OFF_6H;
code char at __CONFIG7L _conf9 = _EBTR_0_OFF_7L & _EBTR_1_OFF_7L;
code char at __CONFIG7H _conf10 = _EBTRB_OFF_7H;
void init_cpu() {
/* INT Osc with 8MHz */
OSCCON = 0x70; /* 01110000 */
}
void delay(unsigned int dly)
{
while(--dly > 0);
}
void main()
{
init_cpu();
OSCTUNE = 0; // oscillator tuning register:
// internal oscillator low-frequency source select bit disabled
// frequency multiplier PLL for INTOSC enable bit disabled
// center frequency
ADCON1 = 0x0f; // All ports digital
// See 18F2620 data sheet, p. 94
ADCON2 = 0x05; // Set AN10-AN12 on PORTB as digital I/O
// See p. 224 of 18F2620 data sheet
TRISB = 0; // All PORTB lines as outputs
//RCON = 0x0f; // reset control register: default interrupt priority, hardware reset
while(1)
{
PORTB = 0x55; // Flash 8 LEDs on PORTB in checkerboard pattern
delay(50); // at approx 5 Hz
PORTB = 0xAA;
delay(50);
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user