Witam wszystkich Ten kawalek kodu nie pracuje poprawnie pomimo ze w debuggerze pracuje ! Ma tylko zapalic diode LED czerwona przez wymuszenie pinu A0=0. Realizuje to przez wskaznik do funckji jak podaje przyklad kompilatora CCS "ex_qsort.c":
#include <18F2550.h>
#byte LATA = 0xF89 #byte TRISA = 0xF92 //#device *=16 // 16 bit pointers
// *** ROM program locations *** // #build( reset=0x0A00, interrupt=0x0A00+8) #org 0x0000, 0x0A00-1 { } // bootloader
// CPU clock (config determined in bootloader) #define FREQ_CPU 48000000 // 48Mhz #use delay ( CLOCK = FREQ_CPU, RESTART_WDT )
#define LED_RED PIN_A0 #define RED_ON output_low( LED_RED ) #define RED_OFF output_high( LED_RED )
typedef void (*HandlerFun) (); void hRedOn() {RED_ON;} void hRedOff() {RED_OFF;}
//---------------------------------------------------------- void main (void) { HandlerFun hFun;
delay_ms( 10 ); // need to wait for PLL? LATA = 0xff; // all leds off! TRISA = 0x0; // all outputs delay_ms( 100 );
hRedOn(); // force CCS to this link function hRedOff();
hFun = hRedOn; while(1) { (*hFun)(); // like in example "ex_sort.c" but here not working!!! //goto_address(hFun);// not working also! //hRedOn(); // WORKING!!! restart_wdt(); }
return; }
Ktos zna ten bug?