This snipet has been copied from parallax and should work with pic. Use 4MHz resonator or change Define setting if different clock will be used.
Al.Code:Define OSC = 4 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 25 ' 9600 Baud @ 4MHz, 0,16% DEFINE HSER_CLROERR 1 ' Clear overflow automatically EN con 1 A0 con 2 S0 con 3 S1 con 4 S2 con 5 S3 con 6 nLED con 7 pRED con 12 pGREEN con 6 pBLUE con 5 Pinx var (pic pin connected to the output) RED var word GREEN var word BLUE var word Start: low A0 high S0 high S1 low nLED high EN MainLp: gosub Color debug "R", dec3 RED debug " G", dec3 GREEN debug " B", dec3 BLUE debug cr goto MainLp Color: low S2 low S3 count pinx, pRED, RED high S3 count pinx, pBLUE, BLUE high S2 count pinx, pGREEN, GREEN return end




Bookmarks