![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
I wrote this simple code Code: #include <system.h>
#pragma DATA _CONFIG1H, _INTIO1_OSC_1H
#pragma DATA _CONFIG2L, _BOR_OFF_2L
#pragma DATA _CONFIG2H, _WDT_OFF_2H
#pragma DATA _CONFIG4L, _LVP_OFF_4L
#pragma CLOCK_FREQ 8000000
void main(void)
{
set_bit( osccon, IRCF2 ); //8 MHz
set_bit( osccon, IRCF1);
set_bit( osccon, IRCF0 );
trisb=0;
trisa=0;
porta=0;
portb=0;
porta.1=1;
delay_s(2);
porta.2=1;
while(1){
}
}
How come?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #2 | |
| Code: #pragma DATA _CONFIG1H, _INTIO1_OSC_1H Code: set_bit( osccon, IRCF2 ); //8 MHz
set_bit( osccon, IRCF1);
set_bit( osccon, IRCF0 );
Code: osccon,IRCF0=1;
osccon,IRCF1=1;
osccon,IRCF2=1;
Code: osccon=0x72; These can be simplified if you want Code: trisa=trisb=0;
porta=portb=0;
And this can be simplified too Code: while(1); Quote:
Probably nothing to do with it, but your "porta.1=1" and such should be "lata.1=1". Use the latch/shadow registers instead of the ports and you'll avoid weird problems later.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 18th July 2008 at 01:29 AM. | ||
| |
| | #3 |
|
wow wierd i did this: Code: #include <system.h>
#pragma DATA _CONFIG1H, _INTIO2_OSC_1H
#pragma DATA _CONFIG2L, _BOR_OFF_2L
#pragma DATA _CONFIG2H, _WDT_OFF_2H
#pragma DATA _CONFIG4L, _LVP_OFF_4L
#pragma CLOCK_FREQ 8000000
void main(void)
{
osccon=0x72; //8 MHz
trisb=trisa=0;
porta=portb=0;
lata.1=1;
delay_s(1);
lata.2=1;
while(1){
}
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #4 |
| So it's happy with lata.1/2, but not with porta.1/2? How strange! Oh well, you should be using the LAT's anyway on 18F's.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 18th July 2008 at 01:43 AM. | |
| |
| | #5 |
|
yeah its pretty wierd but as long as it works. ill be sure to use lata for pic18F from now on. by the way im away from home and am writing this on a psp.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #6 |
|
Are you using current limiting resistors on the LEDs? If not, it is possible that the Read/Modify/Write instruction won't work properly using the porta register. Using lata is the preferred method anyway. Which PIC are you using? Some pins are TTL level and others are Schmitt Trigger level pins.
__________________ Inside every little problem, is a big problem trying to get out. | |
| |
| | #7 |
|
it was happening on 2 PICs. My Junebug(18F1320) and a 18F248. But all is well and im happy lol edit: also i due have 2 resistors on it. (100ohm)
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 18th July 2008 at 11:13 AM. Reason: Forgot to say | |
| |
| | #8 |
|
If you want, measure the voltage on the pins driving the LEDs when the LEDs are on. If it is equal or less than 2V, then that was the problem but with the 100Ω resistors it should be above 2V according to the spec sheet.
__________________ Inside every little problem, is a big problem trying to get out. Last edited by kchriste; 19th July 2008 at 04:32 AM. | |
| |
|
| Tags |
| boostc, flaw |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| BoostC Charlieplexed PWM 32 | Mike, K8LH | Micro Controllers | 140 | 27th March 2009 11:19 AM |
| BoostC 12F683 Serial I/O Example | Mike, K8LH | Micro Controllers | 5 | 2nd October 2008 07:21 PM |
| BoostC USART 18F | AtomSoft | Micro Controllers | 9 | 29th June 2008 05:02 PM |
| BoostC question.. AddressOf | Mike, K8LH | Micro Controllers | 8 | 25th June 2008 12:20 AM |
| math.h and lib for BoostC? | futz | Micro Controllers | 3 | 31st March 2008 06:29 AM |